"Do" syntax for binding of void values

Since ATS2 is used to write more and more imperative code, let me propose a
modest syntactic extension. A new keyword “do” is introduced, such that:

let
do f()
in
// something
end

is a short-hand for

let
val () = f()
in
// something
end

It is of course quite limited compared to a full-blown “val” binding (e.g.
void-value with a proof cannot be bound this way), but that’s the point.
There is a lot of noise with all the “val () =” cropping up in imperative
code.

I got this idea from R. Harper’s talk “The future of SML”, at
http://www.cs.cmu.edu/~rwh/talks/mlw13.pdf (syntax for imperative code)

Thanks for the suggestion.

I have to say that I do not plan to introduce ‘do’ into ATS at this point.

I went over the slides of Bob Harper’s talk.

My understanding of his notation is that

‘val x = ’ is meant for ‘exp’ to be pure and do can have
effects.

In ATS, you could have

val x = foo(y)

where foo returns a value and also generates some effects.
There is no segregation of effects. So whatever we get from introducing ‘do

into ATS is cosmetic and cosmetic only. I feel ‘val () = …’ is a a bit
verbose but keeps the
syntax uniform.

PS: If we are do support monadic style of programming in ATS, then
mimicking Haskell’s
do-notion should be a reasonable thing to do.On Friday, March 13, 2015 at 4:16:57 AM UTC-4, Artyom Shalkhakov wrote:

Since ATS2 is used to write more and more imperative code, let me propose
a modest syntactic extension. A new keyword “do” is introduced, such that:

let
do f()
in
// something
end

is a short-hand for

let
val () = f()
in
// something
end

It is of course quite limited compared to a full-blown “val” binding (e.g.
void-value with a proof cannot be bound this way), but that’s the point.
There is a lot of noise with all the “val () =” cropping up in imperative
code.

I got this idea from R. Harper’s talk “The future of SML”, at
http://www.cs.cmu.edu/~rwh/talks/mlw13.pdf (syntax for imperative code)

Thanks for the suggestion.

I have to say that I do not plan to introduce ‘do’ into ATS at this point.

I went over the slides of Bob Harper’s talk.

My understanding of his notation is that

‘val x = ’ is meant for ‘exp’ to be pure and do can have
effects.

In ATS, you could have

val x = foo(y)

where foo returns a value and also generates some effects.
There is no segregation of effects. So whatever we get from introducing
‘do ’
into ATS is cosmetic and cosmetic only. I feel ‘val () = …’ is a a bit
verbose but keeps the
syntax uniform.

OK, no problem.