[Perl5-syntax] How to test for a role in a method signature
Michael G Schwern
schwern at pobox.com
Tue Mar 8 23:30:34 GMT 2011
On 2011.3.9 7:13 AM, Buddy Burden wrote:
>> 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.
Ahh. I see it the other way around. Int, Str, Num and all are types as
opposed to classes. And then Moose's has => isa takes a type or a class.
Looking at the Moose docs, I guess they make it clear that they're not types
but "type constraints", though I think that distinction is lost on most.
"Predefined constraint" is also accurate
>>> 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.
True. You are right that "constraint" is the proper generic term.
Call them all "constraints" with the thing on the left a "type constraint" and
the thing on the right a "free form constraint"? Or less correctly but more
usefully, a "where constraint".
--
We do what we must because we can.
For the good of all of us,
Except the ones who are dead.
-- Jonathan Coulton, "Still Alive"
More information about the Perl5-syntax
mailing list