Skip to content

Add "Non-Standard Array Literals" by allowing juxtaposition of macro and array #23519

@cdsousa

Description

@cdsousa

TLDR: Please, allow parsing @foo[1, 2, 3] as a shortcut for @foo([1, 2, 3]).

Too many times, when using StaticArrays, I write stuff like

@SArray[1 2; 3 4] * v

which fails with ERROR: syntax: invalid macro use "@((typed_vcat SArray (row 1 2) (row 3 4)))"
I then add a space between @SArray and [1 2; 3 4] which also fails since the macro tries to consume the whole [1 2; 3 4] * v expression.
The right way to do it

@SArray([1 2; 3 4]) * v

It would be nice to be able to this without the parentheses...
Yes, I know, it's not that cumbersome to type two extra characters... but on the other hand, this syntax is available and making it work will hopefully not introduce many accidental bugs.

This could be seen as a kind of "Non-Standard Array Literals".
(related: #8934, #7128, #6960, #8892, #7128)

(Had I the knowledge of Julia parser I would open a PR instead of an issue, but I'm a null at scheme.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]parserLanguage parsing and surface syntax

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions