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

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Jan 19 17:21:02 PST 2014


On Sun, Jan 19, 2014 at 09:41:20PM +0000, digitalmars-d-bounces at puremagic.com wrote:
> On Friday, 17 January 2014 at 05:30:45 UTC, H. S. Teoh wrote:
> >Now, if we modify this sentinel to instead record the location of the
> >code that first initialized it (via __FILE__ and __LINE__ default
> >parameters perhaps), then we can set it up to print out this
> >information at a convenient juncture, so that the source of the
> >uninitialized reference can be determined. *Then* perhaps it will be
> >a start of a
> 
> Which is easy to do (in theory). Page zero is over a thousand unique
> 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.


T

-- 
There's light at the end of the tunnel. It's the oncoming train.


More information about the Digitalmars-d mailing list