![]() | This article is rated Start-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||
|
|
Isn't the statment about the void type being the unit type not true? If unit is a mathmatical type that allows only one value, then void would not meet this qualification because, as is stated in the page, it contains no values. -- NotQuiteEXPComplete 03:03, 9 August 2006 (UTC)
There are no () in Clean. ~~ —Preceding unsigned comment added by 91.124.209.143 ( talk) 06:46, 3 December 2007 (UTC)
The C standard (ISO/IEC 9899:1999) states:
6.2.5 Types
[...]
19 The
void
type comprises an empty set of values; it is an incomplete type that cannot be completed.
So it is clearly a bottom type, not a unit type. I don't know how to fix this, as it is also about C++, C# and Java which I don't know. -- Army1987 ( talk) 10:01, 13 March 2008 (UTC)
void
type or something, which as mentioned in the article is not that important. Regardless of what it says, void
is used where the unit type would mostly be used in other languages; for example, as the return type of functions that don't return anything. In type theory, it's not possible to have a function that returns the bottom type, because there are no values of this type for it to get from anywhere, so you could never write it (unless the function also took in an argument of the bottom type, but then nobody could ever call it). (The bottom type corresponds to "false" in
Curry-Howard correspondence; and it is impossible to prove "x -> false" unless "x" was also false.) Evaluating something of the bottom type would produce an error, e.g. in Haskell, which is completely different from a function that doesn't return anything in C. --
Spoon! (
talk)
20:45, 23 August 2008 (UTC)I also think this is wrong. It's of course true that if we translate ML or Haskell then int -> unit
becomes void (*)(int)
, but the C way of thinking says that this function does not return a value, not that it returns a trivial value. (I wouldn't call this the bottom type either, though. There are no values of type void, but that's not what it means in this case. You can't write void x = f()
. The C family just has a complicated function call system where functions types comprise a list (possibly empty) of arguments and an optional return type, where the omission of a return type is written void
.) C does have a unit type, though: struct {}
. It is not commonly used. —
brighterorange (
talk)
05:39, 2 March 2009 (UTC)
Pierce in TAPL notes that void
corresponds to the Unit type, while Bottom would correspond to function which cannot return, e.g. abort
or a continuation.
Type theory | Imperative languages | Inhabitants | Storage requirements |
---|---|---|---|
Unit | void |
1 | log2 1 = 0 b |
Bottom | __noreturn__ |
0 | log2 0 = not defined |
— Ruud 22:49, 18 May 2011 (UTC)
http://en.wikipedia.org/?title=Unit_type&diff=309807458&oldid=309758990 -- 124.78.228.114 ( talk) 13:44, 27 August 2009 (UTC)
What about this?
#include <stdio.h> void f(void) { puts("in f."); } void g(void) { puts("in g."); return f(); } int main(void) { g(); return 0; }
It compiles on gcc (last time I checked), and it works as expected. -- 92.229.73.235 ( talk) 07:01, 8 March 2010 (UTC)
A nice theoretical presentation, similar to unit+type at the nLab would make a nice addition to this article. 99.153.64.179 ( talk) 19:55, 26 June 2013 (UTC)
In the line: "It should not be confused with the zero or bottom type, which allows no values and is the initial object in this category" should this not be referring to Empty type? Or is this a nuance of the category of types? --Gert7 ( talk · contribs) 23:13, 14 December 2023 (UTC)
![]() | This article is rated Start-class on Wikipedia's
content assessment scale. It is of interest to the following WikiProjects: | |||||||||||||||||||||||||||
|
|
Isn't the statment about the void type being the unit type not true? If unit is a mathmatical type that allows only one value, then void would not meet this qualification because, as is stated in the page, it contains no values. -- NotQuiteEXPComplete 03:03, 9 August 2006 (UTC)
There are no () in Clean. ~~ —Preceding unsigned comment added by 91.124.209.143 ( talk) 06:46, 3 December 2007 (UTC)
The C standard (ISO/IEC 9899:1999) states:
6.2.5 Types
[...]
19 The
void
type comprises an empty set of values; it is an incomplete type that cannot be completed.
So it is clearly a bottom type, not a unit type. I don't know how to fix this, as it is also about C++, C# and Java which I don't know. -- Army1987 ( talk) 10:01, 13 March 2008 (UTC)
void
type or something, which as mentioned in the article is not that important. Regardless of what it says, void
is used where the unit type would mostly be used in other languages; for example, as the return type of functions that don't return anything. In type theory, it's not possible to have a function that returns the bottom type, because there are no values of this type for it to get from anywhere, so you could never write it (unless the function also took in an argument of the bottom type, but then nobody could ever call it). (The bottom type corresponds to "false" in
Curry-Howard correspondence; and it is impossible to prove "x -> false" unless "x" was also false.) Evaluating something of the bottom type would produce an error, e.g. in Haskell, which is completely different from a function that doesn't return anything in C. --
Spoon! (
talk)
20:45, 23 August 2008 (UTC)I also think this is wrong. It's of course true that if we translate ML or Haskell then int -> unit
becomes void (*)(int)
, but the C way of thinking says that this function does not return a value, not that it returns a trivial value. (I wouldn't call this the bottom type either, though. There are no values of type void, but that's not what it means in this case. You can't write void x = f()
. The C family just has a complicated function call system where functions types comprise a list (possibly empty) of arguments and an optional return type, where the omission of a return type is written void
.) C does have a unit type, though: struct {}
. It is not commonly used. —
brighterorange (
talk)
05:39, 2 March 2009 (UTC)
Pierce in TAPL notes that void
corresponds to the Unit type, while Bottom would correspond to function which cannot return, e.g. abort
or a continuation.
Type theory | Imperative languages | Inhabitants | Storage requirements |
---|---|---|---|
Unit | void |
1 | log2 1 = 0 b |
Bottom | __noreturn__ |
0 | log2 0 = not defined |
— Ruud 22:49, 18 May 2011 (UTC)
http://en.wikipedia.org/?title=Unit_type&diff=309807458&oldid=309758990 -- 124.78.228.114 ( talk) 13:44, 27 August 2009 (UTC)
What about this?
#include <stdio.h> void f(void) { puts("in f."); } void g(void) { puts("in g."); return f(); } int main(void) { g(); return 0; }
It compiles on gcc (last time I checked), and it works as expected. -- 92.229.73.235 ( talk) 07:01, 8 March 2010 (UTC)
A nice theoretical presentation, similar to unit+type at the nLab would make a nice addition to this article. 99.153.64.179 ( talk) 19:55, 26 June 2013 (UTC)
In the line: "It should not be confused with the zero or bottom type, which allows no values and is the initial object in this category" should this not be referring to Empty type? Or is this a nuance of the category of types? --Gert7 ( talk · contribs) 23:13, 14 December 2023 (UTC)