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

Syntactic sugar to receive on channels within terms #16

Open
np opened this issue Nov 3, 2015 · 1 comment
Open

Syntactic sugar to receive on channels within terms #16

np opened this issue Nov 3, 2015 · 1 comment

Comments

@np
Copy link
Owner

np commented Nov 3, 2015

<-c could be made a term (as in Go). For instance (<-c : A) would desugar to a receive action let x : A <- c.

Given some type inference the syntax <-c would work without type annotation.

More precisely given an action act all the occurrences (within the terms in act) of a <-c gets replaced by a fresh variable (say x_c). All the receive actions are then combined in parallel and occurs just before act.
All the channels on which we receive must then be distinct, which is enforced because of the parallel combination.

Example:

split de[d,e]
c <- (<-d : Int) + (<-e : Int)

Becomes:

split de[d,e]
(let (x_d : Int) <- d | let (x_e : Int) <- e).
c <- (x_d + x_e)

The biggest advantage of this syntax is that being shorter it pushes the programmer to write more parallel receives which leads to more convenient types.

Caveat

As mentioned in Issue #8, <-c within a local definition should have a specific syntax (using <= instead of =) to avoid suggesting that one can freely replace such definitions.

I suggest to forbid receive expression to be under additional binders. The worse would be that the type of the received message depends on such additional binder. Less critical but \(x : A)-> (recv c : B) would suggest that the receive is down when the function is called. For instance this would be rejected:

d <- (\(x : A)-> (<-c : B))
@np np added the enhancement label Nov 3, 2015
np added a commit that referenced this issue Dec 26, 2015
In short:

* `send c t`       can now be written as `c <- t`.
* `recv c (x : A)` can now be written as `let x : A <- c`.

Moreover:

* One can now use `;` in place of `.`.
* One can use the keyword `split` before splits.
* `<- c` is recognized as a term and `let x : A <= t` as an action.
  These are not handled yet (Issue #16).

Finally ling-fmt as evolved to treat this syntax change:

* Albert.cf has been improved with the changes above except for the
  keyword `split`. This syntax version is now frozen.
* Benjamin.cf has been created as an identical copy of Ling.cf so
  far. Now when Ling.cf changes one should update Benjamin.cf.
@np
Copy link
Owner Author

np commented Dec 26, 2015

Updated the syntax.

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

1 participant