Abridged closures #103
Replies: 4 comments
-
For some reason it's tricky for me to run your branch without running into segfaults? My actual objection this proposal, though, is that it breaks the rule that es state needs to be externalizable. Without abridged closures:
With abridged closures:
I'm not totally sure what's causing the segfault per se, but even if that were fixed, this last command could never succeed with an abridged closure, because the value of |
Beta Was this translation helpful? Give feedback.
-
I see what you mean about the segfaults after compiling with Your perception of abridged closures isn't quite correct. Internally, they are still closures, whether imported into the environment as strings from a parent shell or as Closure objects created in the current shell.
I hope you see the difference now.
I'd argue that if you need the full value, you shouldn't be echo'ing it in the first place, but i can understand if that's problematic. I'm not pushing too hard for this to be included honestly. |
Beta Was this translation helpful? Give feedback.
-
Oh, I see. I made some unfair assumptions about what the segfaults were hiding :). So, if I'm understanding correctly now, this ends up being more of a magic-echo feature than a fundamental change to how closures are formatted. I think that's a lot more palatable. |
Beta Was this translation helpful? Give feedback.
-
No worries, i'm skeptical when newly proposed code causes segfaults too. :) |
Beta Was this translation helpful? Give feedback.
-
Printing cyclical closures, once the code is re-enabled to do so, causes a lot of output, especially when nesting occurs.
To use an example similar to that in #4:
Can you spot the value bound to
a
in the second line?To avoid that noise, i have created memreflect/es-shell@abridge-closures that instead produces much cleaner output by default:
My rationale is that there is no way to modify any of the values in the closure binding without using another closure created using the same bindings, meaning there is no reason to know the values.
At the same time, it still helps to know that it's a closure, instead of seeing only
@ * {a=$*}
, which leads you to believe it sets a dynamic variablea
— that's what the Elvish shell does, and while i have accepted that's just how Elvish works, es isn't Elvish.Do you think this should be added to es?
Beta Was this translation helpful? Give feedback.
All reactions