Skip Menu |

This queue is for tickets about the Scalar-Does CPAN distribution.

Report information
The Basics
Id: 80434
Status: resolved
Priority: 0/
Queue: Scalar-Does

People
Owner: Nobody in particular
Requestors: DAMI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: change API : single-argument does(..) would check against $_
Maybe it's too late to change the API ... but nevertheless here is a suggestion : The fact that does(..) returns a curried function when called with one single argument doesn't seem very useful to me. Actually, I peeked into the module tests, and this feature doesn't even seem to be tested. On the contrary, what could be quite useful would be if the single-arg version checked against $_ (i.e. does($role) would be equivalent to does ($_, $role)). When used together with given/when, this would yield : given ($data) { when(does('ARRAY')) {...} when(does('HASH')) {...} ... } This would be quite elegant, don't you think ?
I'll think about it. The original intention was to allow some sort of infix-like syntax: if ($object ~~does 'ARRAY') { ... } But it turns out to not work so nicely. I thought I'd discovered another use of curried coderefs for Moo type constraints, but actually they're not much use there.
OK, I'm convinced. Thanks to "given" using lexical $_, and the fact that the underscore prototype isn't going to do the trick, it's not going to be pretty, and it's going to need PadWalker.
Implemented in 0.008.