[Perl5-syntax] How to test for a role in a method signature

Buddy Burden barefootcoder at gmail.com
Tue Mar 8 20:13:33 GMT 2011


Michael,

>> In my head, I just call them "types" ... when you say
>> "Foo::Bar $foo", the "Foo::Bar" part isn't _technically_ a class; it's
>> actually a type that happens to correspond to a class.  But I suppose
>> that's really a semantic distinction (and/or an implementation
>> detail).

> We could call them types if types didn't already mean something specific in
> Moose.

But what it specifically means is what we're talking about, right?
Whether applied to an attribute or a method parameter, a "type" in
Moose is merely a constraint on what can and cannot be assigned to it.
 What we tend to call "types" (Int, Str, Num, and so forth) are
actually more like predefined constraints ... a subset of all the
possible types.

At least that's my take on it.

>> We could refer to them as "constraints" I suppose ... type
>> constraints, class constraints, and role constraints. <shrug>
>
> Technically they are a constraint, but "where" is already called constraints,
> and that lines up with vocabulary in other languages like SQL.

That's true.  Although all types devolve to a "where" underneath.  But
I see the value in making a distinction, sure.


            -- Buddy



More information about the Perl5-syntax mailing list