develooper Front page | perl.perl6.language | Postings from March 2005

&wrap, &call and goto &sub

Thread Next
From:
Autrijus Tang
Date:
March 16, 2005 04:46
Subject:
&wrap, &call and goto &sub
Message ID:
20050316124603.GA89891@aut.dyndns.org
Just a quick question.  In Pugs t/op/arith.t we have:

    sub tryeq_sloppy ($lhs, $rhs, ?$todo1 = '') {
	...
	ok($lhs==$rhs,$ todo);
	...
    }

But it breaks the $?CALLER based error reporting, because
it introduces another layer of caller.

In Perl5, I'd do this:

    { local @_ = ($lhs == $rhs, $todo); goto &ok; }

Does that form still work with Perl 6?  Or should I use this?

    { local &_ := &ok; call($lhs == $rhs, $todo); }

However, I did not see A/E/S06 specifying that call() will assume the
&goto semantic of erasing itself from the caller chain, so I hesitate
to implement it that way.

Is using wrap/call the correct choice here, or is there another way
to do it that I missed?

Thanks,
/Autrijus/


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About