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

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

Thread Previous | Thread Next
From:
Ralph Mellor
Date:
November 1, 2018 12:28
Subject:
Re: what type $in,$out and $err is
Message ID:
CAPLR5Seo1nwWNj+EL33x3uehLJ=bV00MsXgT3CJOCEUR1RpKGw@mail.gmail.com
On Sun, Oct 28, 2018 at 7:26 PM Xiao Yafeng <xyf.xiao@gmail.com> wrote:

> I'm curious about what type of $in is on Proc class.


`$in` isn't "on `Proc` class".

`$in` is a *parameter* of the `.new` *method*.


> I mean, if $in is IO::Pipe object


As a *parameter* of the `.new` method *declaration* the type of `$in` is
not explicitly specified. When a parameter's type is not explicitly
specified
it defaults to the type `Any`.

The type of the corresponding `:in` *argument*  in a *call* of the `.new`
method is of whatever type you choose to pass. Any ordinary value is
a sub-type of `Any` so the method will accept it. For example, `True`
and `False` are ordinary values so will be accepted.

Besides, just curious, why choose '_' as default it looks strange....
>

It's '-', not '_'.

'-' is a 50 year old or more unix convention that, when used for a filename
or pipe name means, depending on context, the standard input or output
handles of a process.

cf https://stackoverflow.com/a/8045639/1077672

hth

--
raiph

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