On Tue, 8 Jun 2004, Matthew Walton wrote: > Ingo Blechschmidt wrote: > > > One should be able to unwrap $subref using > > $id.unwrap(); > > Something tells me that you shouldn't be able to do that. Wrapping is an > operation on the subref, which implies very strongly to me that > unwrapping should also be an action on the subref. > > > Or, given $id, it'd be cool if you could get the original $subref: > > my $origsubref = $id.sub(); > > > > Additionally, $id could coerce to an ID number in numeric context, so > > $subref.unwrap($id); > > would still be valid code (==> TIMTOWTDI). > > At the very least you'd have to be able to do that as well, I get this > uneasy feeling about having to do $id.unwrap();. unwrap would be the > wrong method anyway - it implies unwrapping $id itself, which seems > wrong because $id isn't wrapped, it's wrapped around something else. > Maybe $id.remove() or $id.tear_off() or $child.give_present($id), which > would cause unwrapping to happen very, very quickly and messily.
I agree that unwrap is the wrong name for that. Personally, I'd much rather have a more generic name, like undo, and have more than just wrappers use it. Consider (highly speculative): sub big_long_and_nasty (...) { my @consequences; LEAVE { @consequences ». undo(); } ... unshift @consequences, $subjref.wrap({...}) // die $horribly; ... } Where we can add to @consequences anything else that we'll need to undo to clean up on our way out. Maybe not that important, since I think the current thinking is my $id = $subref.wrap({...}) is leave {.undo()}; which might be even handier (though I think that would unwrap it as it falls out of that scope, instead of at the end of the subroutine, making it hard to deal with many nested blocks if you want to revert everything at the end of the whole sub). > On the other hand, what happens when you call $id.unwrap() (or > $subref.unwrap($id)) if $id is an object? What happens to $id? Does it > turn into some kind of limbo object? Does it become undefined? Is it > right for $subref.unwrap($id) to be able to do that to $id? Is it right > for $id to be able to do it to itself? > > Hmm. Not a very useful email really. Oh well. It's too hot to think > straight. Same here. -- Adam Lopresto http://cec.wustl.edu/~adam/ Her hair glistened in the rain like nose hair after a sneeze. (Chuck Smith, Woodbridge)