Actually looking at the bytecode, it is inlined. I performed this little experiment: MyClass>>foo MyNullClass new ifNil: [ Transcript show: 'Nil';cr ] ifNotNil: [ Transcript show: 'NotNil';cr ] So what it really does is MyNullClass new == nil ifTrue: [ Transcript show: 'Nil';cr ] ifFalse: [ Transcript show: 'NotNil';cr ]. (Well, the #ifTrue:ifFalse: is also inlined) So actually subclassing UndefinedObject doesn't work either, because of the #==. Also I think (I'm not completely sure about this), the #== doesn't perform a lookup and the VM takes care of that, so there is no way to change it's behavior by overriding it. About how to workaround... I have no idea =( Cheers, Alejandro 2014/1/22 Sean P. DeNigris <sean@clipperadams.com>
I'm missing something here... I tried implementing: MyNullClass>>#ifNil: nilBlock ifNotNil: notNilBlock nilBlock value. But the notNilBlock is evaluated. I'm assuming it's being inlined. Is that right? How do I workaround?
I also tried subclassing UndefinedObject, with the same result.
Any ideas?
----- Cheers, Sean -- View this message in context: http://forum.world.st/Null-Object-Pattern-tp4738574.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.