DMD OSX / Segfault 11

Robert M. Münch via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 4 00:11:51 PST 2016


On 2016-02-03 13:29:15 +0000, anonymous said:

> Still missing "class". I know I'm being pedantic, but if you're being 
> sloppy here, how do I know that you're not being sloppy where it 
> matters?

You are right, sorry. I was to focused on the problem part...


>>> If anything, you should be casting between Value* and BaseOperator*
>>> (both pointer types) if you want to do something with pointers.
>> 
>> I tried this, but that doesn't work either.
> 
> Yeah, you can't check if the downcast succeeded this way. Casts between 
> pointers always succeed (and then fail horribly at run-time).

Aha, that's my missing link. I didn't know that and it makes it all clear.

IMO that's a not to underestimate trap. Since I can use the . notation 
instead of -> when using pointers, I would have expected that casting 
will work the same with both variants as well...

>> But am I not getting a copy then? I want to avoid copying objects as
>> much as possible.
> 
> No, you're not getting a copy. Classes are reference types. That means, 
> variables of class types are references already. They're pointers in 
> disguise.

Ok. Seems I was really confused. Thanks a lot.

-- 
Robert M. Münch
http://www.saphirion.com
smarter | better | faster



More information about the Digitalmars-d-learn mailing list