-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make $status
available in the interactive loop
#66
Conversation
The variable is called $status for cultural compatibility with rc and direct compatibility with $bqstatus.
Given that it's only in the interactive loop, seems mostly harmless, but... let me sit on this for a bit. Given $status is also referenced in the exception handling, there's probably some edge case where the behaviour is different (e.g if you redefine status in fn-dispatch or fn-prompt and then somehow eof), though I don't think it would cause actual harm. I guess a safe option would be to keep the existing $result variable for the exception handling and never use $status. My preference as a user for this sort of thing is to surface it in the prompt, which I guess this also enables. |
for prior attempts context #33 I agree that the only real value of this is in interactive use, in shell and in the prompt, as there's no "checking it after the fact" in scripts -- can just capture the evaluation result as one normally does. ; x = 1
; echo $status
1 I'm not commenting from my personal machine, so I can't test whether it's the case here. Here's a use-case of
|
hyphenrf: I didn't see there was previous context here -- thanks for posting that. I should take a closer look at prior art before throwing ideas around. Nice that we came up with essentially exactly the same change. And yes, you're right about assignments setting wryun: I think I see what you're talking about? Something like this?
I guess that's bad, but IMO the main problem there is
|
Looking at this again, the other thing that makes me a bit wary is that it might be confusing to users to have status only in the interactive loop and bqstatus everywhere. This made me look at $status in rc. Given that es seems to have inherited bqstatus from rc, if we're going to have a status maybe it would be nice to have an rc style status? e.g.
But in case it wasn't already clear, as far as I'm concerned if you're keen enough about something feel free to merge it; active maintainer wins IMO! |
I think you have a good point about the asymmetry of it -- that seems like a bummer for people who didn't opt into that asymmetry on purpose. And I'm definitely not interested in adding One thing about es that I'm a little dissatisfied with is the "big lift" of redefining I think I might close this PR and instead propose documenting this as a caveat in the man page. |
Hmm, could add a hook function to interactive-loop or dispatch? e.g. if a function %dispatch-result is defined, call it with the result as the argument? tbh, it still has those problems you identify with explicit control flow and still pollutes the global namespace, but it somehow seems cleaner and more functional to me. |
Maybe. Thinking about it, I do consider addressing the flexibility of the REPL to be better than what I've proposed in this PR (generality and extensibility is the es way!) But it's also a much bigger design task. Personally, the most common things I think about changing in
Trying it out -- with a hacked es that does the above, putting the following by itself in
This simple version isn't quite as sophisticated as would be preferred -- no dynamic scoping for
This is, to me, the largest open question. These are the least extensible part of I personally have my Thoughts on any of this? As an aside, here's my favorite way to edit
|
With canonical extensions (#131), this can be closed. |
The creatures feep, but I think this creature is well-justified and expected by the "average" user.