fn test {x:int} (x:int(x)): bool(x <= 0) = (x <= 0) /* Case 1.a */
fn test {x:int} (x:int(x)): bool(0 <= x) = (0 <= x) /* Case 1.b */
fn test {x:int} (x:int(x)): bool(x <= 0 && 0 <= x) = (x <= 0) * (0 <= x) /* Case 2 */
fn test {x:int} (x:int(x)): bool(x == 0) = (x = 0) /* Case 3 */
fn test {x:int|x==0} (x:int(x)): bool(x == 0) = (x = 0) /* Case 4 */
fn test {x:int|x==0} (x:int(x)): bool(true) = (x = 0) /* Case 4 */
'==' is not used in the dynamics. Please use '=' instead. For Case 4, you can actually have:
Yes, = is both a keyword and a special operator.
Right now, '==' is idle. If you like, you can add the following macro:
macdef ==(x, y) = (,(x) = ,(y))
ATS largely follows the ML tradition:
= for equality
:= for assignment
Le jeudi 5 février 2015 19:35:57 UTC+1, gmhwxi a écrit :Yes, = is both a keyword and a special operator.
Right now, '==' is idle. If you like, you can add the following macro:
macdef ==(x, y) = (,(x) = ,(y))
It works, that's nice. What about adding this in the default environment which ATS automatically loads? Or would this break something?
ATS largely follows the ML tradition:
= for equality
:= for assignmentFor assignment as side effect, only. I don't know if “val x = y” can properly be called an assignment or if there is a better word (formally, that's a declaration).
I did use == for reference quality somewhere in my code. Personally, I
prefer = over == as it is the symbol used in mathematics.
--
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 ats-lang-user...@googlegroups.com.
To post to this group, send email to ats-lan...@googlegroups.com.
Visit this group at http://groups.google.com/group/ats-lang-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/ats-lang-users/c233f355-aba7-4e20-8418-397c5b392b87%40googlegroups.com.