digitalmars.D - [D typesystem] What is the type of null?
- Justin Johansson <no spam.com> Oct 12 2010
- Stanislav Blinov <blinov loniir.ru> Oct 12 2010
- Justin Johansson <no spam.com> Oct 12 2010
- Justin Johansson <no spam.com> Oct 12 2010
- Stanislav Blinov <blinov loniir.ru> Oct 12 2010
- Adam D. Ruppe <destructionator gmail.com> Oct 12 2010
- Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> Oct 12 2010
- Justin Johansson <no spam.com> Oct 12 2010
- Justin Johansson <no spam.com> Oct 12 2010
- Bruno Medeiros <brunodomedeiros+spam com.gmail> Oct 29 2010
- Stanislav Blinov <stanislav.blinov gmail.com> Oct 29 2010
- el muchacho <nicolas.janin gmail.com> Oct 31 2010
- lurker <lurk lurking.org> Oct 31 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Oct 12 2010
- retard <re tard.com.invalid> Oct 13 2010
- dsimcha <dsimcha yahoo.com> Oct 12 2010
- "Simen kjaeraas" <simen.kjaras gmail.com> Oct 12 2010
Given that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem? - JJ
Oct 12 2010
12.10.2010 17:52, Justin Johansson пишет:Given that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem? - JJ
writeln(typeid(typeof(null))) yields void* :)
Oct 12 2010
On 13/10/2010 1:34 AM, Stanislav Blinov wrote:12.10.2010 17:52, Justin Johansson пишет:Given that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem? - JJ
writeln(typeid(typeof(null))) yields void* :)
Are you suggesting that the type of "null" is opaque or merely saying what the D compiler says without an opinion? - JJ
Oct 12 2010
On 13/10/2010 2:17 AM, Stanislav Blinov wrote:There was a smile there, no? Alright, alright, joking mood off.
Of course there was a(n implied) smile there, sorry I forgot the opcodes :-) :-) :-) - JJ
Oct 12 2010
12.10.2010 18:43, Justin Johansson пишет:On 13/10/2010 1:34 AM, Stanislav Blinov wrote:12.10.2010 17:52, Justin Johansson пишет:Given that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem? - JJ
writeln(typeid(typeof(null))) yields void* :)
Are you suggesting that the type of "null" is opaque or merely saying what the D compiler says without an opinion?
Personally, I'd suggest that null has no 'type' by itself, but adapts to whatever type is applicable in certain use case. It may be viewed as if D had several different 'nulls' for every existing and user-defined reference type.
Oct 12 2010
I agree with what the compiler says: void*. null is literally a pointer into the void - there's nothing there for it to point to.
Oct 12 2010
On 10/12/10 9:51 CDT, Adam D. Ruppe wrote:I agree with what the compiler says: void*. null is literally a pointer into the void - there's nothing there for it to point to.
Problem: char[] a = null; The answer to the OP's question is simple: null's type is not expressible in D. Andrei
Oct 12 2010
On 13/10/2010 2:04 AM, Andrei Alexandrescu wrote:On 10/12/10 9:51 CDT, Adam D. Ruppe wrote:I agree with what the compiler says: void*. null is literally a pointer into the void - there's nothing there for it to point to.
Problem: char[] a = null; The answer to the OP's question is simple: null's type is not expressible in D.
Andrei
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al. Justin
Oct 12 2010
On 13/10/2010 2:41 AM, Simen kjaeraas wrote:Justin Johansson <no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type?
I'm sure others can throw their thoughts in on this, however for me, on the other side of the world, it is way beyond the witching hour and I need to retire at least a few hours before the sun rises. Until later, enjoy your daylight time, Justin
Oct 12 2010
On 13/10/2010 17:27, retard wrote:Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote:Justin Johansson<no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type?
It's much easier to write a specification, a compiler, and an automatic theorem prover for a language with a sane type system. The types and transitions are expressible with simple rules of logic. Now you need ad hoc special cases. Nothing else.
It may be true that such would make it easier to write an automatic theorem prover, maybe also a specification, but would it really make it easier to write a compiler for such a language? And more importantly, even if it was easier, would the language actually be a better and more useful language? Better as in a general-purpose programming language. I suspect not, and Justin's implication that D's inability to accurately express the type of null is somehow a severe shortcoming seems to me like wacky formal-methods fanboyism or some other similar crazyness... -- Bruno Medeiros - Software Engineer
Oct 29 2010
Bruno Medeiros wrote:On 13/10/2010 17:27, retard wrote:Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote:Justin Johansson<no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type?
It's much easier to write a specification, a compiler, and an automatic theorem prover for a language with a sane type system. The types and transitions are expressible with simple rules of logic. Now you need ad hoc special cases. Nothing else.
It may be true that such would make it easier to write an automatic theorem prover, maybe also a specification, but would it really make it easier to write a compiler for such a language? And more importantly, even if it was easier, would the language actually be a better and more useful language? Better as in a general-purpose programming language. I suspect not, and Justin's implication that D's inability to accurately express the type of null is somehow a severe shortcoming seems to me like wacky formal-methods fanboyism or some other similar crazyness...
AFAIK, N/A is a fairly legit theorem outcome (laws involving infinity, or integral of sin(x)/x come to mind).
Oct 29 2010
Le 29/10/2010 21:02, Bruno Medeiros a écrit :On 13/10/2010 17:27, retard wrote:Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote:Justin Johansson<no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type?
It's much easier to write a specification, a compiler, and an automatic theorem prover for a language with a sane type system. The types and transitions are expressible with simple rules of logic. Now you need ad hoc special cases. Nothing else.
It may be true that such would make it easier to write an automatic theorem prover, maybe also a specification, but would it really make it easier to write a compiler for such a language? And more importantly, even if it was easier, would the language actually be a better and more useful language? Better as in a general-purpose programming language. I suspect not, and Justin's implication that D's inability to accurately express the type of null is somehow a severe shortcoming seems to me like wacky formal-methods fanboyism or some other similar crazyness...
I don't know if it has already been cited here, but this is a good read : Much Ado About Nothing: Putting Java’s Null in its Place http://www.ccs.neu.edu/scheme/pubs/dissertation-cobbe.pdf
Oct 31 2010
el muchacho Wrote:I don't know if it has already been cited here, but this is a good read : Much Ado About Nothing: Putting Java’s Null in its Place http://www.ccs.neu.edu/scheme/pubs/dissertation-cobbe.pdf
I only saw words Haskell and Java there. Was enough to make me vomit and made my brain refuse to read more. We don't need Java bloat or Haskell academics in practical systems programming. There's no way to avoid null.
Oct 31 2010
Justin Johansson <no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type? -- Simen
Oct 12 2010
Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote:Justin Johansson <no spam.com> wrote:The answer to the OP's question is simple: null's type is not expressible in D.
That is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al.
I'm curious - why does null need such a specific type?
It's much easier to write a specification, a compiler, and an automatic theorem prover for a language with a sane type system. The types and transitions are expressible with simple rules of logic. Now you need ad hoc special cases. Nothing else.
Oct 13 2010
== Quote from Justin Johansson (no spam.com)'s articleGiven that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem? - JJ
I see it as a polysemous value, kind of like 1. typeof(1) is int. auto foo = 1; makes foo an int. However, the literal 1 can be assigned to any integral type, even ones that an int can't be. Similarly, null can be assigned to class references and pointers to any type, even though a void* can't be.
Oct 12 2010
On Tue, 12 Oct 2010 15:52:36 +0200, Justin Johansson <no spam.com> wrote:Given that if a function should return something, and that function may return null in, at least reference type return scenarios, one would expect that "null" has a type. What is the type of "null" in the D typesystem?
The type of null is Null. This type is castable to any pointer or reference type, as well as arrays. Now, this is of course not true, but it could have been. -- Simen
Oct 12 2010









Justin Johansson <no spam.com> 