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

Michael G Schwern schwern at pobox.com
Mon Mar 7 11:23:20 GMT 2011


On 2011.3.7 9:08 PM, Piers Cawley wrote:
>> A simpler approach would be for MXD to special case "does coerce" in parsing.
>>  If it sees a role called "coerce" while parsing it warns.  Ta da!
> 
> Works for me. Though should it still warn if, for some reason, there's
> a role 'coerce' already loaded?

Initially it probably should, since it's highly unlikely such a role will
exist and the important thing is to aid in migrating MXMS code.


> I like the proposal I saw floating around somewhere of using 'will
> coerce' as the 'right' syntax for indicating coercion. It seems to fit
> the place better than either 'is' or 'does'.

Yes, "is" and "will" appear to be what Perl 6 is using for parameter traits now.


-- 
60. "The Giant Space Ants" are not at the top of my chain of command.
    -- The 213 Things Skippy Is No Longer Allowed To Do In The U.S. Army
           http://skippyslist.com/list/



More information about the Perl5-syntax mailing list