Aaron Sherman <[EMAIL PROTECTED]> wrote:
> On Sat, 2005-04-30 at 22:24 +0800, Autrijus Tang wrote:
> > On Sat, Apr 30, 2005 at 09:13:26AM -0500, Abhijit Mahabal wrote:
> > > I do not see how any auto-threading occurs in that code. It is completely
> > > innocuous in that sense, and I don't think that is what horrified David.
> > > What was troublesome was, I think:
> > >     my Str|Int $x;
> > >     $x.foo(); # runs two methods and returns a junction
> >
> > That would be absolutely horrible.
> 
> Then tell me what $!.can("chars") returns, assuming that $! is
> implemented as an "any" junction of Int and Str values? My take would be
> that it returns false|true, which is true in a boolean context, but feel
> free to talk me out of it.

`$!` is an `Exception` (or somesuch) object, not a `Str|Int`, but in
general, that depends on the contents of the variable.  If a Str|Int
was assigned a `Str`, `can` would be true; if it were assigned an
`Int`, `can` would be false.  If it were assigned a disjunction of a
`Str` and an `Int`, it'd return `true|false`, which evaluates to
`true`.

> Str|Int is simply the type of "Yes"|1, isn't it? That would certainly
> make signature matching on different kinds of junctive types trivial.

Nope.  The type `Str|Int` doesn't mean "this variable contains a
disjunction of `Str`s and `Int`s"; it means "This variable can contain
either a `Str` or an `Int`."  (Actually, it means "this variable can
contain anything consistent with a Str or Int", which also includes
subclasses and certain junctions.)  When you see a declaration like:

    my Foo $bar;

Think of it as being like:

    my $bar where { $_ ~~ Foo };

> If the latter, then what is the type of "Yes"|1?

I suspect it's `Disjunction of Str | Int`.

-- 
Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

"I used to have a life, but I liked mail-reading so much better."

Reply via email to