Skip to content

Manual: please explicitly explain the .foo[] syntax. #1047

@zhenya1007

Description

@zhenya1007

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|.[]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions