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

[superseded] ref syntax for lvalue expressions: byRef: myref=x[1].foo[2] #11824

Closed
wants to merge 14 commits into from
Prev Previous commit
Next Next commit
fix comments
  • Loading branch information
timotheecour committed Jan 23, 2020
commit 0e66b9a8bb71c9a4c9f0ea243f13b6f1c48b78d8
2 changes: 1 addition & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

- Added `os.isRelativeTo` to tell whether a path is relative to another

- Added `sugar.byAddr` allowing a ref syntax for lvalue expressions
- Added `sugar.byAddr` allowing a reference syntax for lvalue expressions, analog to C++ `auto& a = expr`.

## Library changes

Expand Down
6 changes: 3 additions & 3 deletions lib/pure/sugar.nim
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ proc splitDefinition*(def: NimNode): tuple[lhs: NimNode, rhs: NimNode, exported:
expectKind(result.lhs, nnkIdent)

macro byAddr*(def: untyped): untyped {.since: (1,1).} =
## Defines a ref alias for lvalue expressions. The expression is evaluated
## only once, and any side effects will only be evaluated once, at declaration
## time.
## Defines a reference syntax for lvalue expressions, analog to C++ `auto& a = expr`.
## The expression is evaluated only once, and any side effects will only be
## evaluated once, at declaration time.
runnableExamples:
var x = @[1,2,3]
byAddr: x1=x[1]
Expand Down