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

Alternative syntax with a classic memory read/write style #8

Open
np opened this issue Oct 8, 2015 · 4 comments
Open

Alternative syntax with a classic memory read/write style #8

np opened this issue Oct 8, 2015 · 4 comments

Comments

@np
Copy link
Owner

np commented Oct 8, 2015

An example:

cmd_syntax_example =
  cmd(i : [?Int, ?Int], o : !Int)
     i[i0,i1]
     ( (x : Int) := @i0
     | (y : Int) := @i1).
     @o := (x + y)

Essentially recv c (x : A) becomes (x : A) := @c and send c t becomes @c := t.

So far the use of @ conflicts with its use to embed terms but so far I think it goes nicely with the idea of a location.

A more aggressive change would be to always write channels with a @ symbol. This could help making things more obvious at many levels but also look noisy and reminds of too many scripting languages...

@np np added the enhancement label Oct 8, 2015
@diakopter
Copy link
Collaborator

lol

and reminds of too many scripting languages...

On Thu, Oct 8, 2015 at 6:25 AM, Nicolas Pouillard [email protected]
wrote:

An example:

cmd_syntax_example =
cmd(i : [?Int, ?Int], o : !Int)
i[i0,i1](%28x : Int%29 := @i0
| %28y : Int%29 := @i1).
@o := (x + y)

Essentially recv c (x : A) becomes (x : A) := @c and send c t becomes @c
:= t.

So far the use of @ conflicts with its use to embed terms but so far I
think it goes nicely with the idea of a location.

A more aggressive change would be to always write channels with a @
symbol. This could help making things more obvious at many levels but also
look noisy and reminds of too many scripting languages...


Reply to this email directly or view it on GitHub
#8.

Sent by an Internet

@np
Copy link
Owner Author

np commented Nov 4, 2015

Here is an alternative proposal reusing ! and ? instead of @. Moreover combined with issue #16, #17, and #18, a receive action is presented as a let binding of a recv term.

The example could then be:

cmd_syntax_example =
  cmd(i : [?Int, ?Int], o : !Int)
     i[i0,i1]
     ( let x = (?io : Int)
     | let y : Int = ?i1).
     !o := x + y

or shorter:

cmd_syntax_example =
  cmd(i : [?Int, ?Int], o : !Int)
     i[i0,i1]
     !o := (?io : Int) + (?i1 : Int)

@np
Copy link
Owner Author

np commented Dec 18, 2015

I'm leaning towards following the syntax of Go for sending/receiving on channels.

The idea is to use "<-" as the visual marker for what goes in or out of a channel.
I want to keep using "let" for variables (as opposed to channels). However I think it was wrong to use "=" for a receive even when embedded in a term.
I think we should keep "=" as the visual marker for permanent definitions for which one can freely substitute away the definition.

In summary here is my new proposal:

  • Send: chan <- term
  • Receive: let x : A <- chan
  • Local definition: let x : A = term (unchanged)

For the new syntax for #16, we should not use "=" for the reason mentioned above. We could extend the syntax of receive but this not really good to explain. I'm leaning towards using "<=" as a mix: let x : A <= term.

For instance let x : Int <= (<-i0) + (<-i1) is translated to (let xi0 : Int <- i0 | let xi1 : Int <- i1). let x : Int = xi0 + xi1. Here again the marker "<=" tells you that this is going to introduce some receives with "<-" and one definition with "=".

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.
@taruti
Copy link

taruti commented Jan 12, 2016

<= could cause confusion with "less-or-equal".

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

3 participants