Diagrams for types; unit vs void?

72 views
Skip to first unread message

Brandon Barker

unread,
Mar 10, 2018, 9:35:45 AM3/10/18
to ats-lang-users
I find the following diagram helpful to sort of know what's what in Scala: https://www.scala-lang.org/old/node/128.html

Now, ATS is very different, I'm not sure such a diagram could even make sense (it isn't a language that deals with subclassing much as I understand it). But if anything like it is possible (and maybe more than one diagram is necessary), I think it could be helpful to place these early on in one of the ATS documentation sections/books.

Now I get the sense that ATS's void is actually the unit type, is this correct? What is the uninhabited type in ATS, if any?

Hongwei Xi

unread,
Mar 10, 2018, 9:44:34 AM3/10/18
to ats-lan...@googlegroups.com
ATS's void is unit. The name 'void' refers to the fact that the memory needed
for the void-value is 0 bytes. Unfortunately, there is no type in C of 0 size (I did
try struct{}). This is the place where a theorist and an engineer differ fundamentally.
One really needs a theorist's C in order to compile ATS faithfully.

--
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/c0a94aab-c802-493e-a786-3e44e5cd3173%40googlegroups.com.

Hongwei Xi

unread,
Mar 10, 2018, 9:46:50 AM3/10/18
to ats-lan...@googlegroups.com
There are many uninhabited types in ATS.

For instance ([false] void) is such a type. Or you can use {a:type} a
(that is, forall a. a).

On Sat, Mar 10, 2018 at 9:35 AM, Brandon Barker <brandon...@gmail.com> wrote:

--

Brandon Barker

unread,
Mar 10, 2018, 10:34:13 AM3/10/18
to ats-lang-users
Ah, interesting - to get around that, does ATS just translate every void value assiagnment as the execution of a C function call returning void?


On Saturday, March 10, 2018 at 9:44:34 AM UTC-5, gmhwxi wrote:
ATS's void is unit. The name 'void' refers to the fact that the memory needed
for the void-value is 0 bytes. Unfortunately, there is no type in C of 0 size (I did
try struct{}). This is the place where a theorist and an engineer differ fundamentally.
One really needs a theorist's C in order to compile ATS faithfully.
On Sat, Mar 10, 2018 at 9:35 AM, Brandon Barker <brandon...@gmail.com> wrote:
I find the following diagram helpful to sort of know what's what in Scala: https://www.scala-lang.org/old/node/128.html

Now, ATS is very different, I'm not sure such a diagram could even make sense (it isn't a language that deals with subclassing much as I understand it). But if anything like it is possible (and maybe more than one diagram is necessary), I think it could be helpful to place these early on in one of the ATS documentation sections/books.

Now I get the sense that ATS's void is actually the unit type, is this correct? What is the uninhabited type in ATS, if any?

--
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.

Hongwei Xi

unread,
Mar 10, 2018, 10:51:13 AM3/10/18
to ats-lan...@googlegroups.com
Pretty much so.

Sometimes, not being able to have values of 0 bytes causes wastefulness.

For instance, a map from keys to items becomes a set if the items are of the
type void. If I write code like this, the code can pass typechecking but is to be
stopped by the C compiler. Instead, I have to use integer 0 as a dummy item
but doing so wastes memory and CPU cycles.

I read that ancient Romans did not have a numeral for zero. By that, you could
infer that they were a very pratical people :)

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.

Yannick Duchêne

unread,
Jul 29, 2018, 9:17:22 PM7/29/18
to ats-lang-users


Le samedi 10 mars 2018 15:44:34 UTC+1, gmhwxi a écrit :
ATS's void is unit. The name 'void' refers to the fact that the memory needed
for the void-value is 0 bytes. Unfortunately, there is no type in C of 0 size (I did
try struct{}). This is the place where a theorist and an engineer differ fundamentally.
One really needs a theorist's C in order to compile ATS faithfully.

I just wondered about the status of `void` after this:

        fn f(void): int = 0

… it does not compile and the same with `unit`. Only this do:

         fn f(): int = 0

After that comment, I guess it’s half‑intended and half‑not.

Yannick Duchêne

unread,
Jul 29, 2018, 9:20:17 PM7/29/18
to ats-lang-users
By the way, what was the issue with an empty struct? No really empty?

Hongwei Xi

unread,
Jul 29, 2018, 10:10:09 PM7/29/18
to ats-lan...@googlegroups.com
For instance, gcc does not support an empty struct.

--
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.
Reply all
Reply to author
Forward
0 new messages