Adding the ?. null verification

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 19 15:23:33 PDT 2014


On Thu, Jun 19, 2014 at 02:37:33PM -0700, H. S. Teoh via Digitalmars-d wrote:
[...]
> Here, I've made it so that the .exists field is only present if the
> wrapped type T doesn't have a null value that can serve as an
> existence marker.
> 
> I'm not sure if this is the right thing to do 100% of the time,
> because conceivably, somebody might want to distinguish between a
> pointer field that has null as a value, as opposed to a pointer field
> that doesn't exist. But I think such cases should be very rare; and
> cutting out the .exists field where unnecessary also keeps the size of
> the wrapper struct minimal, so that it's easier for the compiler's
> optimizer to completely optimize it out for pointer values.
> (Unfortunately I ran into a snag with gdc due to latest dmd features
> that haven't made it into gdc, so I haven't been able to actually
> check the assembly output -- I'll try to iron that out and post the
> results.)
[...]

Unfortunately, it appears that opDispatch has become too complex to be
inlined, so now gdc is unable to simplify it to a series of nested if's.
:-(


T

-- 
It's bad luck to be superstitious. -- YHL


More information about the Digitalmars-d mailing list