Open np opened 8 years ago
lol
and reminds of too many scripting languages...
On Thu, Oct 8, 2015 at 6:25 AM, Nicolas Pouillard notifications@github.com 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 https://github.com/np/ling/issues/8.
Sent by an Internet
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)
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:
chan <- term
let x : A <- chan
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 "=".
<=
could cause confusion with "less-or-equal".
An example:
Essentially
recv c (x : A)
becomes(x : A) := @c
andsend 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...