tracking issue: remove Value& out parameters #1136

Open
opened 2026-02-23 22:52:55 +00:00 by pennae · 5 comments
Owner

main has pretty resonable support for returning values directly since pointer tagging happened. we should remove out parameters from all signatures and return proper values instead.

and numerous others probably

`main` has pretty resonable support for returning values directly since pointer tagging happened. we should remove out parameters from all signatures and return proper values instead. - [x] Expr::eval (https://gerrit.lix.systems/c/lix/+/5219) - [x] primops (https://gerrit.lix.systems/c/lix/+/5456) - [x] EvalState::callFunction (https://gerrit.lix.systems/c/lix/+/5253) - [x] EvalState::autoCallFunction (https://gerrit.lix.systems/c/lix/+/5291) - [x] EvalState::concatLists (https://gerrit.lix.systems/c/lix/+/5450) - [x] EvalState::eval\* (https://gerrit.lix.systems/c/lix/+/5254) - [x] EvalState::mk\* (https://gerrit.lix.systems/c/lix/+/5305, https://gerrit.lix.systems/c/lix/+/5303, others) - [x] Evaluator::evalLazily (https://gerrit.lix.systems/c/lix/+/5292) - [x] ~~getDerivation~~ - [x] parseJSON (https://gerrit.lix.systems/c/lix/+/5448) and numerous others probably
Member

This issue was mentioned on Gerrit on the following CLs:

  • comment in cl/5219 ("libexpr: migrate Expr::eval to return a Value, take 2")
  • commit message in cl/5305 ("libexpr: Migrate EvalState::mkOutputString to return a Value")
  • commit message in cl/5307 ("libexpr/primops/fromTOML: Migrate visit lambda to return a value")
  • commit message in cl/5303 ("libexpr: Migrate mkStorePathString to return a Value")
  • commit message in cl/5301 ("libexpr: Migrate makePositionThunks to return Value tuple")
  • commit message in cl/5308 ("libexpr: Migrate EvalState::mkPos to return a Value")
  • commit message in cl/5309 ("libexpr: Migrate emitTreeAttrs to return a Value")
  • commit message in cl/5446 ("libexpr: Migrate EvalPaths::allowAndSetStorePathString to return a Value")
  • commit message in cl/5453 ("libexpr/primops: Migrate helper fn fetch to return a Value")
  • commit message in cl/5452 ("libexpr/primops: Migrate helper fn fetchTree to return a Value")
  • commit message in cl/5451 ("libexpr/primops: Migrate helper fn anyorall to return a Value")
  • commit message in cl/5450 ("libexpr: Migrate EvalState::concatLists to return a Value")
  • commit message in cl/5449 ("libexpr/primops: Migrate helper fn elemAt to return a Value")
  • commit message in cl/5448 ("libexpr/json-to-value: Migrate parseJSON to return a Value")
  • commit message in cl/5447 ("lixexpr/primops: Migrate import helper fn to return a Value")
  • commit message in cl/5456 ("libexpr/primops: Migrate primops to return Values")
  • commit message in cl/5455 ("libexpr/primops: Migrate addPath to return a Value")
  • commit message in cl/5454 ("libexpr/primops: Migrate derivationStrictInternal to return a Value")
  • commit message in cl/5472 ("libexpr: Delete EvalState::mkSingleDerivedPathString dead function with Value& out param")
<!-- GERRIT_LINKBOT: {"cls": [{"backlink": "https://gerrit.lix.systems/c/lix/+/5219", "number": 5219, "kind": "comment"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5305", "number": 5305, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5307", "number": 5307, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5303", "number": 5303, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5301", "number": 5301, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5308", "number": 5308, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5309", "number": 5309, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5446", "number": 5446, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5453", "number": 5453, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5452", "number": 5452, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5451", "number": 5451, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5450", "number": 5450, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5449", "number": 5449, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5448", "number": 5448, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5447", "number": 5447, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5456", "number": 5456, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5455", "number": 5455, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5454", "number": 5454, "kind": "commit message"}, {"backlink": "https://gerrit.lix.systems/c/lix/+/5472", "number": 5472, "kind": "commit message"}], "cl_meta": {"5219": {"change_title": "libexpr: migrate Expr::eval to return a Value, take 2"}, "5305": {"change_title": "libexpr: Migrate EvalState::mkOutputString to return a Value"}, "5307": {"change_title": "libexpr/primops/fromTOML: Migrate `visit` lambda to return a value"}, "5303": {"change_title": "libexpr: Migrate mkStorePathString to return a Value"}, "5301": {"change_title": "libexpr: Migrate makePositionThunks to return Value tuple"}, "5308": {"change_title": "libexpr: Migrate EvalState::mkPos to return a Value"}, "5309": {"change_title": "libexpr: Migrate emitTreeAttrs to return a Value"}, "5446": {"change_title": "libexpr: Migrate EvalPaths::allowAndSetStorePathString to return a Value"}, "5453": {"change_title": "libexpr/primops: Migrate helper fn fetch to return a Value"}, "5452": {"change_title": "libexpr/primops: Migrate helper fn fetchTree to return a Value"}, "5451": {"change_title": "libexpr/primops: Migrate helper fn anyorall to return a Value"}, "5450": {"change_title": "libexpr: Migrate EvalState::concatLists to return a Value"}, "5449": {"change_title": "libexpr/primops: Migrate helper fn elemAt to return a Value"}, "5448": {"change_title": "libexpr/json-to-value: Migrate parseJSON to return a Value"}, "5447": {"change_title": "lixexpr/primops: Migrate import helper fn to return a Value"}, "5456": {"change_title": "libexpr/primops: Migrate primops to return Values"}, "5455": {"change_title": "libexpr/primops: Migrate addPath to return a Value"}, "5454": {"change_title": "libexpr/primops: Migrate derivationStrictInternal to return a Value"}, "5472": {"change_title": "libexpr: Delete EvalState::mkSingleDerivedPathString dead function with Value& out param"}}} --> This issue was mentioned on Gerrit on the following CLs: * comment in [cl/5219](https://gerrit.lix.systems/c/lix/+/5219) ("libexpr: migrate Expr::eval to return a Value, take 2") * commit message in [cl/5305](https://gerrit.lix.systems/c/lix/+/5305) ("libexpr: Migrate EvalState::mkOutputString to return a Value") * commit message in [cl/5307](https://gerrit.lix.systems/c/lix/+/5307) ("libexpr/primops/fromTOML: Migrate `visit` lambda to return a value") * commit message in [cl/5303](https://gerrit.lix.systems/c/lix/+/5303) ("libexpr: Migrate mkStorePathString to return a Value") * commit message in [cl/5301](https://gerrit.lix.systems/c/lix/+/5301) ("libexpr: Migrate makePositionThunks to return Value tuple") * commit message in [cl/5308](https://gerrit.lix.systems/c/lix/+/5308) ("libexpr: Migrate EvalState::mkPos to return a Value") * commit message in [cl/5309](https://gerrit.lix.systems/c/lix/+/5309) ("libexpr: Migrate emitTreeAttrs to return a Value") * commit message in [cl/5446](https://gerrit.lix.systems/c/lix/+/5446) ("libexpr: Migrate EvalPaths::allowAndSetStorePathString to return a Value") * commit message in [cl/5453](https://gerrit.lix.systems/c/lix/+/5453) ("libexpr/primops: Migrate helper fn fetch to return a Value") * commit message in [cl/5452](https://gerrit.lix.systems/c/lix/+/5452) ("libexpr/primops: Migrate helper fn fetchTree to return a Value") * commit message in [cl/5451](https://gerrit.lix.systems/c/lix/+/5451) ("libexpr/primops: Migrate helper fn anyorall to return a Value") * commit message in [cl/5450](https://gerrit.lix.systems/c/lix/+/5450) ("libexpr: Migrate EvalState::concatLists to return a Value") * commit message in [cl/5449](https://gerrit.lix.systems/c/lix/+/5449) ("libexpr/primops: Migrate helper fn elemAt to return a Value") * commit message in [cl/5448](https://gerrit.lix.systems/c/lix/+/5448) ("libexpr/json-to-value: Migrate parseJSON to return a Value") * commit message in [cl/5447](https://gerrit.lix.systems/c/lix/+/5447) ("lixexpr/primops: Migrate import helper fn to return a Value") * commit message in [cl/5456](https://gerrit.lix.systems/c/lix/+/5456) ("libexpr/primops: Migrate primops to return Values") * commit message in [cl/5455](https://gerrit.lix.systems/c/lix/+/5455) ("libexpr/primops: Migrate addPath to return a Value") * commit message in [cl/5454](https://gerrit.lix.systems/c/lix/+/5454) ("libexpr/primops: Migrate derivationStrictInternal to return a Value") * commit message in [cl/5472](https://gerrit.lix.systems/c/lix/+/5472) ("libexpr: Delete EvalState::mkSingleDerivedPathString dead function with Value& out param")
sky1e self-assigned this 2026-04-10 20:48:48 +00:00
Member

@sky1e Are you still working on this? I have a potential solution for getDerivation and potentially others but don't want to steal your fire if you want to get this over the finish line.

@sky1e Are you still working on this? I have a potential solution for `getDerivation` and potentially others but don't want to steal your fire if you want to get this over the finish line.
Member

@ifreilicht wrote in #1136 (comment):

@sky1e Are you still working on this? I have a potential solution for getDerivation and potentially others but don't want to steal your fire if you want to get this over the finish line.

Maybe I'm missing something, but I don't see any Value& out params in any of the getDerivation(s) functions.

https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L405-L410
This one forces v, so it's using the provided value.

https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L428-L435
This one calls the above with its v parameter.

https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L449-L454
This one evaluates its vIn as a function.

https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L555-560
And this one calls the previous with its v.

@ifreilicht wrote in https://git.lix.systems/lix-project/lix/issues/1136#issuecomment-18520: > @sky1e Are you still working on this? I have a potential solution for `getDerivation` and potentially others but don't want to steal your fire if you want to get this over the finish line. Maybe I'm missing something, but I don't see any `Value&` out params in any of the `getDerivation(s)` functions. https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L405-L410 This one forces `v`, so it's using the provided value. https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L428-L435 This one calls the above with its `v` parameter. https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L449-L454 This one evaluates its `vIn` as a function. https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/get-drvs.cc#L555-560 And this one calls the previous with its `v`.
Member

I believe with https://gerrit.lix.systems/c/lix/+/5472 that will be all Value& out parameters removed, though I wouldn't mind a second pair of eyes to check if I missed anything.

I believe with https://gerrit.lix.systems/c/lix/+/5472 that will be all `Value&` out parameters removed, though I wouldn't mind a second pair of eyes to check if I missed anything.
Member

Ah you're right, I didn't understand what forceValue does, I'm still kinda new to the evaluator. That function does still has an out-param in DrvInfos & drvs, but not sure if that's something we also want to fix.

I believe with https://gerrit.lix.systems/c/lix/+/5472 that will be all Value& out parameters removed, though I wouldn't mind a second pair of eyes to check if I missed anything.

That's the only other one I found as well. Wasn't sure if it could be removed. I believe I remember that libexpr was supposed to have a public interface at some point and maybe that's part of it?

Ah you're right, I didn't understand what `forceValue` does, I'm still kinda new to the evaluator. That function does still has an out-param in `DrvInfos & drvs`, but not sure if that's something we also want to fix. > I believe with https://gerrit.lix.systems/c/lix/+/5472 that will be all `Value&` out parameters removed, though I wouldn't mind a second pair of eyes to check if I missed anything. That's the only other one I found as well. Wasn't sure if it could be removed. I believe I remember that `libexpr` was supposed to have a public interface at some point and maybe that's part of it?
Sign in to join this conversation.
No milestone
No project
No assignees
4 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1136
No description provided.