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

Re: Appropriate last words

Thread Previous | Thread Next
From:
Brandon Allbery
Date:
October 25, 2018 23:07
Subject:
Re: Appropriate last words
Message ID:
CAKFCL4WkU5etKPnMPkvtspvomrB10Zj1d9c1OpkPnBjHdOOEXg@mail.gmail.com
You can't actually wrap print that way, can you? Or rather, if that works
it wouldn't be specific to $*ERR.

On Thu, Oct 25, 2018 at 6:16 PM Brian Duggan <bduggan2@gmail.com> wrote:

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


-- 
brandon s allbery kf8nh
allbery.b@gmail.com

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