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

Re: what type $in,$out and $err is

Thread Previous | Thread Next
From:
Brad Gilbert
Date:
October 28, 2018 22:43
Subject:
Re: what type $in,$out and $err is
Message ID:
CAD2L-T2ChDAcRCT-Q=jDScuFqyx=bp-xziQeyo12iivsRK7dpw@mail.gmail.com
That is talking about the arguments for the method/subroutine call.

The way you pass in $in as True, is to add `:in`

    run "cat", "-n", :in, :out;

The `:in` and `:out` are exactly the same as `:in(True)` `:out(True)`

    run "cat", "-n", :in(True), :out(True);

Which is also the same as `in => True`

    run "cat", "-n", in => True, out => True;

There is even a shortcut for `in => $in`

    my $in = True;
    my $out = True;

    run "cat", "-n", :$in, :$out;
    run "cat", "-n", in => $in, out => $out;
    run "cat", "-n", :in($in), :out($out);

---

Basically that is a way to indicate that you are actually interested
in those filehandles,
and for the routine to set them up for you.
On Sun, Oct 28, 2018 at 2:26 PM Xiao Yafeng <xyf.xiao@gmail.com> wrote:
>
> I'm curious about what type of $in is on Proc class. As described in perl6doc:
> $in, $out and $err are the three standard streams of the
> to-be-launched program, and default to "-" meaning they inherit the
> stream from the parent process. Setting one (or more) of them to True
> makes the stream available as an IO::Pipe object of the same name,
> like for example $proc.out.
>
> I mean, if $in is IO::Pipe object, how can I pass it True?
>
> > my IO::Pipe $bb = True;
> Type check failed in assignment to $bb; expected IO::Pipe but got Bool
> (Bool::True)
>   in block <unit> at <unknown file> line 4
>
> I'm interested in the underlying mechanics of  it. Please enlighten me.
>
> Besides, just curious, why choose '_' as default it looks strange....

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