Non-null objects, the Null Object pattern, and T.init

Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com> Ola Fosheim Grøstad" <ola.fosheim.grostad+dlang at gmail.com>
Mon Jan 20 04:20:56 PST 2014


On Monday, 20 January 2014 at 01:22:34 UTC, H. S. Teoh wrote:
>> adresses. All you have to do is to convert null-tests to a 
>> range
>> test. E.g. (addr&MASK)==0
>
> It's not that simple. In assembly, usually the pointer value is 
> just a
> base address, you add the field offset on top of that before 
> you even
> attempt to load anything from memory. So you can't use 
> "different nulls"
> to represent different source locations that easily.

Why not? You don't trap address zero, the MMU traps pages of 4K 
size on x86.

But when you have an explicit nullptr test you will have to mask 
it before testing the zero-flag in the control register.


More information about the Digitalmars-d mailing list