Skip to content

C API: Improve value initializers #10577

Open
@roberth

Description

Is your feature request related to a problem? Please describe.

Not having an EvalState here restricts the implementation of the C API to implementations of Nix that have a global garbage collector or equivalent; there's no reason to not take an EvalState that isn't used in the API for future proofing.

And, ignoring that, having the distinct argument ordering feels like it's a bit of a footgun.

--- #10537 (comment)

Describe the solution you'd like

Both issues follow from the format of the other initializers, but I'm not sure that it's a problem in this case, as the implementation doesn't allocate. Nonetheless, it's a risk, I suppose.

To be on the safe side, we could

* Change the argument order to put the out parameter last

* Add an `EvalState *`, which will be unused

* s/nix_init/nix_value_init? This is extra breaking, but that's actually helpful I think. The API is still in development, so that's ok.

--- #10537 (comment)

Describe alternatives you've considered

Additional context

Priorities

Add 👍 to issues you find important.

Metadata

Assignees

No one assigned

    Labels

    c apiNix as a C library with a stable interfacefeatureFeature request or proposal

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions