On Sun, 5 Jan 2003, Murat Ünalan wrote: > > Properties *can* be smart-matched: > > > > print "creditcard" if $var.prop().{CreditCard} ~~ 'VISA'; > > or: > > print "creditcard" if $var.prop{CreditCard} ~~ 'VISA'; > > or: > > print "creditcard" if $var.CreditCard ~~ 'VISA'; > > > I think this is similar to "John Williams" suggestion: > > print "creditcard" if CreditCard( $var ) eq 'VISA';
Well, no. In my suggestion, CreditCard is a sub which checks whether $var is a valid credit card, returning the card type. In Damian's example, he is assuming $var already has a property assigned to it called CreditCard possibly containing the value 'VISA'. So his has less processing they either of ours. The problem I see with: > print "creditcard" if $var ~~ CreditCard( 'VISA' ); is that CreditCard does not know what $var is. Even if you overload the smartmatch operator on $var's class, it is still comparing $var with the value returned from CreditCard. > sub CreditCard > { > #connect to a "specific" database (VISA, MASTERCARD, ..) > #compare with "non-blocked or valid" cards > } ... > Excerpt: My concept is to have a twofold view about "properties". One > thing that is attributing a type during decleration, and something that > could verified against in other context. All my thinking on that > orginates from Damians Attribute::Type. > > Hopefully i do not confuse you too much. A sub is not a property. It might be a method, which could sometimes look like a property (as in Damian's third example), but you have strayed so far away from properties that you are talking about something else now. ~ John Williams