Skip to content
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

Use a <- v instead of a = append(a, v) #2107

Open
xushiwei opened this issue Feb 15, 2025 · 3 comments
Open

Use a <- v instead of a = append(a, v) #2107

xushiwei opened this issue Feb 15, 2025 · 3 comments

Comments

@xushiwei
Copy link
Member

xushiwei commented Feb 15, 2025

Proposal

In Go:

a = append(a, v)
a = append(a, v1, v2, v3)
a = append(a, b...)

In Go+:

a <- v
a <- v1, v2, v3
a <- b...

Easier to understand.

@xushiwei xushiwei changed the title Use a <- x instead of a = append(a, x) Use a <- v instead of a = append(a, v) Feb 15, 2025
xushiwei added a commit to xushiwei/gop that referenced this issue Feb 15, 2025
xushiwei added a commit that referenced this issue Feb 15, 2025
compileSendStmt: support slice append (#2107)
xushiwei added a commit to xushiwei/gop that referenced this issue Feb 15, 2025
xushiwei added a commit to xushiwei/gop that referenced this issue Feb 21, 2025
xushiwei added a commit that referenced this issue Feb 21, 2025
xushiwei added a commit to xushiwei/gop that referenced this issue Feb 21, 2025
xushiwei added a commit that referenced this issue Feb 21, 2025
#2107 parser: send statement in parseSimpleStmtEx
xushiwei added a commit to xushiwei/gop that referenced this issue Feb 22, 2025
xushiwei added a commit that referenced this issue Feb 22, 2025
#2107 cl: extend compileSendStmt
@akofer
Copy link

akofer commented Mar 9, 2025

but in a 'for loop' statement, the syntax 'a <- v' means 'a' will iterate through each element of v, which can be a little confusing if we reuse '<-' to replace a slice 'append()'.

proposal: it might be better to use 'for a in v' instead of 'for a <- v'.

@xushiwei
Copy link
Member Author

xushiwei commented Mar 9, 2025

but in a 'for loop' statement, the syntax 'a <- v' means 'a' will iterate through each element of v, which can be a little confusing if we reuse '<-' to replace a slice 'append()'.

proposal: it might be better to use 'for a in v' instead of 'for a <- v'.

Related issue: #295 (reopened)

@xushiwei
Copy link
Member Author

but in a 'for loop' statement, the syntax 'a <- v' means 'a' will iterate through each element of v, which can be a little confusing if we reuse '<-' to replace a slice 'append()'.

proposal: it might be better to use 'for a in v' instead of 'for a <- v'.

supported in #2166

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants