Ingo Blechschmidt wrote:
Hello,

quoting Apocalypse 6:

You may ask a subroutine to wrap itself up in another subroutine in
place, so that calls to the original are intercepted and interpreted by
the wrapper, even if access is only through the reference:

   $id = $subref.wrap({
       # preprocessing here
       call;
       # postprocessing here
   }

[...]

The $id is useful for removing a particular wrapper:

$subref.unwrap($id);


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.


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.



Reply via email to