-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
I have looked through the manual, and it did not look to me like you are ever explicitly explaining the .foo[] syntax: it just appears out of the blue in the section on Array Construction as part of the example [.items[].name]
. By analogy with .foo.bar
being syntactic sugar for .foo | .bar
(which you do explain in section .foo
, .foo.bar
), I guessed that the syntax .foo[]
must be syntactic sugar for .foo | .[]
; I have done a bit of experimentation, and so far, I haven't been able to come up with an example that refutes my guess -- but the point of this issue is that I shouldn't have had to guess.
One additional point of confusion for me is that, if I pedantically apply the .foo.bar
desugars to .foo | .bar
line of thinking, I would expect to be able to write .foo.[]
and have it desugar to .foo | .[]
-- but that didn't work for me in my experiments: only .foo[]
syntax was accepted.
If my guess is indeed what you intended (I haven't looked at your parser yet), then I think a logical place to add this information is in the section that describes .[]
. I think a single sentence would do. Perhaps something like
A filter of the form
.foo[]
is equivalent to.foo|.[]