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

sugar: add var x syntax to => #1492

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

zerbina
Copy link
Collaborator

@zerbina zerbina commented Feb 18, 2025

Summary

Allow prefixing parameter names with var, to designate the parameter
as being a var parameter.

Details

Type parameters cannot be inferred as var, and therefore it's
effectively not possible to use the => macro for creating anonymous
procedures where the procedures needs var parameters. The x: T
syntax does exist, but it applies to all preceding parameter, limiting
its usefulness.

To address the aforementioned shortcoming, the var x syntax is now
supported (example: (x, var y) => x), assigning var auto as the
respective parameter's type. Due a NimSkull syntax/parser limitation,
var x cannot be used as the first parameter.

Summary
=======

Allow prefixing parameter names with `var`, to designate the parameter
as being a `var` parameter.

Details
=======

Type parameters cannot be inferred as `var`, and therefore it's
effectively not possible to use the `=>` macro for creating anonymous
procedures where the procedures needs `var` parameters. The `x: T`
syntax does exist, but it applies to all preceding parameter, limiting
its usefulness.

To address the aforementioned shortcoming, the `var x` syntax is now
supported (example: `(x, var y) => x`), assigning `var auto` as the
respective parameter's type. Due a NimSkull syntax/parser limitation,
`var x` cannot be used as the first parameter.
@zerbina zerbina added enhancement New feature or request stdlib Standard library labels Feb 18, 2025
@saem
Copy link
Collaborator

saem commented Feb 18, 2025

/merge

Copy link

Merge requested by: @saem

Contents after the first section break of the PR description has been removed and preserved below:


@chore-runner chore-runner bot added this pull request to the merge queue Feb 18, 2025
Merged via the queue into nim-works:devel with commit 59a0b26 Feb 18, 2025
43 checks passed
@zerbina zerbina deleted the lambda-sugar-var-syntax branch February 19, 2025 22:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stdlib Standard library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants