develooper Front page | perl.perl6.users | Postings from October 2018

Re: Appropriate last words

Thread Previous | Thread Next
From:
Brian Duggan
Date:
October 25, 2018 22:15
Subject:
Re: Appropriate last words
Message ID:
20181025221505.GB14117@localhost
On Thursday, October 25, Richard Hainsworth wrote: 
> >&exit.wrap: -> $status { $exit-args = $status; fail }
>
> Is the call to 'fail' replicating the original action of &exit?

No -- the call to fail is throwing an exception.  The idea
is that the exception could then be caught in the test.

> >&note.wrap: -> |c { $note-args = c; callsame; }
> Does this mean that the next routine in a chain (in this case `exit note ...
> `), so in fact `exit`, is called?

No -- "callsame" is calling the original "note".

> >$*ERR.^find_method('print').wrap: -> |c { True; }
> This wrap I am not so clear about. Why is `^find_method('print') needed?

Since callsame called note (above) note will still print
to stderr -- if we want to intercept this, i.e. to not print
to stderr, we can wrap the 'print' method of $*ERR.

This is just one of doing it...maybe I did more wrapping than
necessary :-)  And in any case, in a test suite, some of
these wraps might have to be temporary. (so that they
don't interfere with code in the test suite)

Brian

Thread Previous | 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