Non-nullable references, again

Michel Fortin michel.fortin at michelf.com
Wed Dec 31 19:12:15 PST 2008


On 2008-12-31 21:50:53 -0500, Daniel Keep <daniel.keep.lists at gmail.com> said:

> Disclaimer: I'm not an expert on compilers.  Plus, I just got up.  :P
> 
> The key is that the parser has to know what "MyClass" means before it 
> can figure out what the "?" is for; that's why it's context-dependant. 
> D avoids this dependency between compilation stages, because it 
> complicates the compiler.  When the parser sees "MyClass", it *doesn't 
> know* that it's a type, so it can't distinguish between a nullable type 
> and an invalid ?: expression.

As far as I know, this can't be done with pointer declarations. Read this:

	a * b;

Is it a multiplication or a declaration of a pointer to type "a"? You 
don't know until you resolve the identifiers. It's the exact same 
situation for using "?" to denote nullable.


> At least, I think that's how it works; someone feel free to correct me 
> if it's not.  :P

I belived the same for some time too, then found the above rebutal.

-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list