-
Notifications
You must be signed in to change notification settings - Fork 400
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
Initial $in
language reference
#1398
Conversation
@amtoine ping as requested |
I think this is a great addition, but I would split it a bit. The language guide is meant as a concise reference for the language. There should be only a short mention of what |
lang-guide/lang-guide.md
Outdated
#### Implicit `$in` | ||
|
||
The preceding example can be simplified even further because `$in |` is implicit at the beginning of a closure. So we can just use the more concise: | ||
|
||
```nushell | ||
ls | update name {str upcase} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this section is misleading because there is no hidden $in
variable in our internal semantics.
Instead part of the custom command/closure semantics is that the first pipeline element of the first pipeline expression will receive the pipeline input to the custom command/closure. (We should make sure that this is both documented in the spec and the general user documentation)
This has the distinct difference that it follows the pipelining semantics instead of the value/variable semantics. Thus it is lazy and carries the pipeline metadata (latter can be considered somewhat of an implementation detail for now)
We may implement optimizations for $in
in the "first element of first pipeline"-position but from an educational perspective with the current semantics of Nushell it is much easier to teach $in
is a special variable that you can use if needed but the pipelining behavior is expressed with |
and the beginning of a custom command/closure block. (Teaching it that way also makes you aware of potential pitfalls, that you can not assume to receive no input in the first pipeline element of a custom command/closure)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough - I'll work on fixing that. Agree that the value/variable semantics are different enough (in streaming vs. collection) to make that a bad analogy.
Thanks! And certainly open to seeing how we can split it out. Regardless, I think The Book needs more discussion of Keep in mind, though, that the README for the Language Guide says the goal is:
I know it "looks" like a tutorial at first glance, but it's really just 10 examples of usage of I also think it's a bit overkill for The Book, which it seems should be the intro/tutorial/digest version, right? |
The goal of the reference is to have a concise overview of Nushell's syntax, kind of like https://doc.rust-lang.org/reference. The readme probably should be reworded to reflect that better. The goal of the book is to teach users how to use the language which can include examples. If we don't keep this distinction strict, we'll end up with two books. I believe you can take most of your text, put it under a new section in https://www.nushell.sh/book/variables.html and in the language reference just add a short enumeration of where |
Thanks for the feedback, and apologies for the delay getting back around to this.
|
I think we can move ahead with this. Thanks for taking the time to update based on our feedback. We can continue to tweak as time goes by, but this is 100% better than what we had. Thanks. |
Here's a first pass at
$in
documentation for the Language Reference Guide. Let me know if I missed any nuances or use-cases.