~ overloading seems to be a little bit confusing

42 views
Skip to first unread message

Julian Fondren

unread,
May 18, 2018, 2:31:08 AM5/18/18
to ats-lang-users
#include "share/atspre_staload.hats"


implement main0
() = (
  println
!("~5 = ", ~5);
  println
!("~5u = ", ~5u);
)


Output:
~5 = -5
~5u = 4294967290

As the second ~ is lnot, bitwise negation.

My expectation was that unsigned numbers would mostly behave like positive numbers with an extra bit.

Is this something that just hasn't come up, or is it intended?

Hongwei Xi

unread,
May 18, 2018, 11:03:10 AM5/18/18
to ats-lan...@googlegroups.com
This is actually intended.

~ is used for the negative sign in ATS2. It is an ML tradition.
Over the years, I feel that this may not be a good choice. Maybe
we should use '-' instead, which makes parsing a little bit more involved.


--
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-users+unsubscribe@googlegroups.com.
To post to this group, send email to ats-lang-users@googlegroups.com.
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/b3188167-a418-42dc-ae98-698cf8fa5784%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages