Note: I forgot to independently PR the syntax for callrefs (used by #2774), so here it is.
Introduce the & syntax to capture and reference calls.
This is used to provide a simple function pointer construction that will be used later to implement full lambdas. However, this is not expected to be used by lambda programmers :)
var ref = &recv.foo
Currently, the syntax is analogous to a simple call (recv.foo) with a prefix &.
On chains, only the last call is captured (. have a higer precedence than &)
var r = &foo.bar.baz
# is equivalent with
var x = foo.bar
var r = &x.baz
Since the syntax is analogous to a call (except the &), there is always a receiver (including the implicit self or sys) and arguments are accepted by the parser.
var r = &foo
# is equivalent with
var r = &self.foo
There is no clear syntax proposal to avoid the capture of a receiver since a receiver is statically expected to resolve the method name.
Note: I forgot to independently PR the syntax for callrefs (used by #2774), so here it is.
Introduce the
&
syntax to capture and reference calls. This is used to provide a simple function pointer construction that will be used later to implement full lambdas. However, this is not expected to be used by lambda programmers :)Currently, the syntax is analogous to a simple call (recv.foo) with a prefix
&
.On chains, only the last call is captured (
.
have a higer precedence than&
)Since the syntax is analogous to a call (except the &), there is always a receiver (including the implicit self or sys) and arguments are accepted by the parser.
There is no clear syntax proposal to avoid the capture of a receiver since a receiver is statically expected to resolve the method name.