-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
allow users to write obscure shell operators with function call syntax #616
Comments
What is the advantage of new syntax:
When this exits (it's even shorter!):
Similarly, why support Contrast with fish shell approach. Fish does not have function calls with round brackets, only commands. In other words, what's Oil philosophy regarding function calls versus commands, substitutions and pipes? P.S. Having said all that, I could never remember all those |
Brainstorm mode on. I wonder if this would be better:
And this:
In other words, |
Yes good question.. this is open to debate, but the rationale is:
A canonical example is:
So basically Well I guess it could if we come up with some canonical serialization... but I'm not sure that is a good idea? Hm. Note the oil literal syntax is |
There are also a bunch of string functions in Python that take integers that I think would be useful in shell:
Although I'm pretty sure Oil won't have method call syntax, so it will be more like I also want the keyword argument syntax, like:
|
Related thread about left-to-right syntax: https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/left-to-right.20syntax.20ideas (Sorry I am switching back and forth between Zulip and github. Github is for stuff I don't want to get "lost" while Zulip is sort of free-form) |
This depends on #636 to break the Python dependency (and maybe the left-to-right syntax evaluation) Won't get to this in 2020, can be done on demand once the infrastructure is there. We are parsing everything we need now, but the evaluator has to be done before doing any of this |
#865 is related |
This came up again in a conversation with Alex from Shell++ We should nail this down; it's one of his key complaints |
Nice. Maybe the simplifications in ruby and crystal can even provide good precedence for keeping the noise level nicely down to whats bearable for typical shell usage measures.
(Compact overview at: https://learnxinyminutes.com/docs/crystal (scroll to "# Functions")) Or, might oil even be able to do without the |
We almost certainly want/need parens, because otherwise functions aren't distinct from procs procs return an integer status value, while functions can return structured data. It's something of an open design question The parens / no parens distinction means "string arguments" vs. "typed arguments" right now. I think functions have only typed arguments, while procs can have both. |
(Now, I'm not sure to which issue the function-call syntax belongs.) In ruby/crystal the parens are also only optional where the call is unambiguous. But I get that you're reasoning to better prefer obvious (explicit) and always consistent syntax. Also, to require parens for all function calls seems consistent to "parens indicate containing expression language". So yeah, not so sure how the inconsistency vs. simplicity would work out if there were more inference done. Maybe a better alternative to keep syntax noise down in oil could be to have idomatic oil only use short, single argument function calls, to avoid long comma and quoting chains. And always use argument vectors (splice array/dict) to pass more values. Not sure what you mean by left-to-right syntax above, but maybe it's related to "piping" vectors?: |
We have a design and implementation for methods and function calls, so closing this old issue Help wanted here - https://www.oilshell.org/blog/2024/01/release-0.19.0.html#ideas-for-contributions-and-feedback |
For users who care about readability and not compatibility. Exact syntax TBD.
${x#/}
=>stripPrefix(x, '/')
${x^^}
=>uppercase(x)
${x@P}
=>promptFormat(x)
${x//pat/replace}
=>replace(x, 'pat', 'replace', 'all')
(although I wanted this to use the left-to-right "pass" syntax, which I'm not sure if we'll get to)Could also add an option to not strip trailing newline, e.g.
commandSub(cmd, newline=true)
https://oilshell.zulipchat.com/#narrow/stream/121540-oil-discuss/topic/Trailing.20Newline.20in.20Command.20Sub
Also:
glob()
for dynamic globbingsplit()
for IFS splitting and other kinds of splittingmaybe()
for empty elisionThe text was updated successfully, but these errors were encountered: