digitalmars.D - [D typesystem] What is the type of null?
- Justin Johansson (6/6) Oct 12 2010 Given that if a function should return something,
- Stanislav Blinov (2/8) Oct 12 2010 writeln(typeid(typeof(null))) yields void* :)
- Justin Johansson (5/16) Oct 12 2010 Are you suggesting that the type of "null" is
- Stanislav Blinov (6/23) Oct 12 2010 There was a smile there, no? Alright, alright, joking mood off.
- Justin Johansson (4/5) Oct 12 2010 Of course there was a(n implied) smile there, sorry I forgot the
- Adam D. Ruppe (3/3) Oct 12 2010 I agree with what the compiler says: void*.
- Andrei Alexandrescu (6/9) Oct 12 2010 Problem:
- Justin Johansson (4/14) Oct 12 2010 That is a sad observation for a language that purports
- Simen kjaeraas (4/8) Oct 12 2010 I'm curious - why does null need such a specific type?
- Justin Johansson (7/14) Oct 12 2010 I'm sure others can throw their thoughts in on this, however
- retard (5/14) Oct 13 2010 It's much easier to write a specification, a compiler, and an automatic
- Bruno Medeiros (12/26) Oct 29 2010 It may be true that such would make it easier to write an automatic
- Stanislav Blinov (3/32) Oct 29 2010 AFAIK, N/A is a fairly legit theorem outcome (laws involving infinity,
- el muchacho (5/34) Oct 31 2010 Hello,
- lurker (2/6) Oct 31 2010 I only saw words Haskell and Java there. Was enough to make me vomit and...
- dsimcha (6/12) Oct 12 2010 I see it as a polysemous value, kind of like 1. typeof(1) is int. auto...
- Simen kjaeraas (6/11) Oct 12 2010 The type of null is Null. This type is castable to any pointer or
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? - JJwriteln(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 пишет:Are you suggesting that the type of "null" is opaque or merely saying what the D compiler says without an opinion? - JJGiven 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? - JJwriteln(typeid(typeof(null))) yields void* :)
Oct 12 2010
12.10.2010 18:43, Justin Johansson пишет:On 13/10/2010 1:34 AM, Stanislav Blinov wrote:There was a smile there, no? Alright, alright, joking mood off. 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.12.10.2010 17:52, Justin Johansson пишет:Are you suggesting that the type of "null" is opaque or merely saying what the D compiler says without an opinion?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? - JJwriteln(typeid(typeof(null))) yields void* :)
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
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.AndreiThat is a sad observation for a language that purports maturity beyond the epoch of C/C++/Java et. al. Justin
Oct 12 2010
Justin Johansson <no spam.com> wrote:I'm curious - why does null need such a specific type? -- SimenThe 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.
Oct 12 2010
On 13/10/2010 2:41 AM, Simen kjaeraas wrote:Justin Johansson <no spam.com> wrote: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, JustinI'm curious - why does null need such a specific type?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.
Oct 12 2010
Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote:Justin Johansson <no spam.com> wrote: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.I'm curious - why does null need such a specific type?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.
Oct 13 2010
On 13/10/2010 17:27, retard wrote:Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote: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 EngineerJustin Johansson<no spam.com> wrote: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.I'm curious - why does null need such a specific type?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.
Oct 29 2010
Bruno Medeiros wrote:On 13/10/2010 17:27, retard wrote:AFAIK, N/A is a fairly legit theorem outcome (laws involving infinity, or integral of sin(x)/x come to mind).Tue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote: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...Justin Johansson<no spam.com> wrote: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.I'm curious - why does null need such a specific type?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.
Oct 29 2010
Le 29/10/2010 21:02, Bruno Medeiros a écrit :On 13/10/2010 17:27, retard wrote:Hello, 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.pdfTue, 12 Oct 2010 17:41:05 +0200, Simen kjaeraas wrote: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...Justin Johansson<no spam.com> wrote: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.I'm curious - why does null need such a specific type?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.
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.pdfI 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
== 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? - JJI 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