Abridged closures #103
Replies: 5 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 |
|
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. |
|
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. |
|
No worries, i'm skeptical when newly proposed code causes segfaults too. :) |
|
I'm revisiting this idea now after a while. Previously, my impression of this idea was that it was punching a hole in the nice However, in #229, I got a better sense of where More recently, in #252, I've been dreaming about adding variable-bound file handles, which would allow files to be opened and their handles bound to a variable, allowing nice variable things like lexical scope, rather than requiring users to rely on the (pretty bad) whole-process fd namespace. The major challenge with this idea is externalization -- how would we put a file handle in a More generally, this could also be useful for an extensible-primitives system that I've been mulling over. Plenty of potential use cases for extensible primitives can be imagined which involve some kind of hard-to-externalize object, or handle to a resource. It could be genuinely useful to allow people to punt on the externalization problem when they're creating a new sort of handle. This could even be used in a possible sci-fi future where continuations are exposed to users. These aren't immediately practical considerations, but I'm trying to think three steps ahead before making design choices. This is all to say that my mind has opened to abridged closures -- particularly as a special case of a more general decoupling of This is largely just daydreaming, but I think it's interesting, and it does enable a number of things that would otherwise be very difficult to make happen. |
Uh oh!
There was an error while loading. Please reload this page.
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
ain 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?
All reactions