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.
On Tuesday, October 24, 2017 at 4:08:39 AM UTC-4, Russoul wrote:
>
> 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 написал:
>>
>>
>> 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 }
>>
>> On Monday, October 23, 2017 at 2:59:09 PM UTC-4, Russoul wrote:
>>>
>>> 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.
>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"ats-lang-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/ats-lang-users/399289b8-d7fc-4143-9e45-68d5e7affa03%40googlegroups.com.