Ergonomics question

102 views
Skip to first unread message

Russoul

unread,
Oct 23, 2017, 2:59:09 PM10/23/17
to ats-lang-users
It is probably a useless question but why do we have "let in end" construct in ats? It is verbose and you have to write a new one in each inner scope, for example inside "if else" statement. Haskell goes well just with "let in" plus it has "where" which is very neat sometimes.

And also "val _ =..."'s go crazy sometimes.

ATS is very expressive which already leads to increased code size.

gmhwxi

unread,
Oct 23, 2017, 8:36:41 PM10/23/17
to ats-lang-users

The let-in-end construct is borrowed from ML: ATS can be said
to belong to the ML family of functional programming languages.

In a call-by-value language, one needs to explicitly specify whether
a value is recursively defined or not. If you don't use 'val', then you
need something else. For instance, one may need to have both let and
letrec.

By the way, ATS support 'where', too:

fun f(x: int): int = y where { val y = x + x }

Russoul

unread,
Oct 24, 2017, 4:08:39 AM10/24/17
to ats-lang-users
About 'val's, in cases when 'val' is used only to bind void result of some expression why can't we omit 'val () =' part ?
And I still don't understand how 'val' helps with explicit notation of whether a value is recursively defined or not. Could you explain it a bit further ?

Missed the fact that 'where' is supported, sorry.


вторник, 24 октября 2017 г., 3:36:41 UTC+3 пользователь gmhwxi написал:

gmhwxi

unread,
Oct 24, 2017, 9:16:06 AM10/24/17
to ats-lang-users

You can write

val () = f(x)
val () = g(x, y)

or you can write (f(x); g(x, y))

The former is declaration and the latter is expression.

Be default, 'val' means no recursion and 'fun' means recursion:

val x = x + 1 // the two x's are different
fun f(x) = f(x-1) // the two f's are the same

The second one is translated into:

val rec f = lam(x) => f(x-1) // the two f's are the same

Of course, you can design other ways to pass this kind of
information (recursion or no recursion). I would say that the
ML-style is quite reasonable. For instance, I introduced 'fnx'
into ATS to indicate the need for tail-call optimization:

fnx f(...) = ...g(...)...
and g(...) = ...f(...)...

The use of 'fnx' goes quite well with the ML-style.

r.mcginnis

unread,
Oct 31, 2017, 11:13:48 PM10/31/17
to ats-lang-users
A very crude hack for the "val () =" issue is to insert an extremely obscure symbol character in your code wherever you wish to write this and compile with a simple script that first replaces the character with "val ()=" before compiling normally.  Also map the symbol to a rarely used key such as back-quote for convenience of typing.

Reply all
Reply to author
Forward
0 new messages