Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

'wrap' from S6

7 views
Skip to first unread message

David Storrs

unread,
Apr 16, 2003, 10:44:04 AM4/16/03
to The Perl6 Language List
From S6:
----
The call to .wrap returns a unique identifier that can later be passed
to the .unwrap method, to undo the wrapping:

&thermo.unwrap($id);
----

Can we add a suppressable warning (similar to "useless use of <foo> in
void context") that says "Id of wrapped function not stored; you will
not be able to unwrap '<foo>'"?

--Dks

Adam D. Lopresto

unread,
Apr 16, 2003, 11:07:03 AM4/16/03
to David Storrs, The Perl6 Language List

Hmmm, I don't think that's necessary. Actually, I wouldn't be surprised in the
least if perl had the introspective power to unwrap a subroutine without that
$id, and if it doesn't I don't see the purpose in forcing it being stored if
you never want to undo the wrap.

However, I do wonder whether the unwrap is as streamlined as it could be.

&thermo.unwrap($id);

looks to me like you need to store two things if you want to be able to undo a
wrap, and one is wholy dependant on the other. Why can't the identifier
returned be some structure that contains both?

$handle = &thermo.wrap(&wrapper);
.
.
.
$handle.unwrap();

It particularly seems useful if you're writing a module that wraps many subs.
There's no reason you should have to store references to all the subs along
with the ids. Actually, I'd argue that .unwrap could be named .undo, and in
general other things could return a handle that could undo them, though I can't
think of any examples off the top of my head.
--
Adam Lopresto
http://cec.wustl.edu/~adam/

perl -le '$_=(split q,",,`$^Xdoc -q japh`)[1].".";y/pj/PJ/;print'

Austin Hastings

unread,
Apr 16, 2003, 12:59:39 PM4/16/03
to David Storrs, The Perl6 Language List

Only with perl6 -w:IrksomeBanalPedantic :)

I think this is one of those things like setting the separator char --
if you do it, you know what you're doing. If you don't save the id, you
didn't want the id.

=Austin


0 new messages