Delete *really* means delete

Simon Wistow simon at thegestalt.org
Thu Feb 24 22:31:59 GMT 2011


On Thu, Feb 24, 2011 at 09:17:41PM +0000, Matt Lawrence said:
> This will remove the caller's reference to the invocant, There's no way of 
> knowing if that's the last reference, copying will keep it alive.

Yeah, that's what I think I was triggering last night.

> Neither of these approaches are particularly intuitive for the caller, you 
> don't normally expect objects to mutate or disappear like this. If that's 
> the lesser of two evils in your situation, fair enough. As long as the 
> weirdness is documented clearly that's fair warning ;-)

To be honest it was more of an intellectual curiosity.

I've used similar techniques against for modules against web services 
where a POST or PUT returns additional information (autogenerated id, 
internal defaults etc etc)

So that 

  $webservice->update($object);

is the same as

  $object = $webservice->update($object);

But stuff disappearing from under you felt a little more ... unexpected.

Really evil thought ... someone else deletes the object from the DB at 
the same time you're using it and your instance becomes undef from 
underneath you.






More information about the london.pm mailing list