Merge: Callref syntax
authorJean Privat <jean@pryen.org>
Wed, 14 Aug 2019 15:22:26 +0000 (11:22 -0400)
committerJean Privat <jean@pryen.org>
Wed, 14 Aug 2019 15:22:26 +0000 (11:22 -0400)
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 :)

```nit
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 `&`)

```nit
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.

```nit
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.

Pull-Request: #2775
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>


Trivial merge