Re: AW: my int( 1..31 ) $var ?

2003-01-08 Thread Damian Conway
Christian Renz wrote: Now, I might be stupid, but I keep asking myself what you would need a property for in this example. Yes. It's important to remember that the shiny new hammer of properties is not necessarily the appropriate tool to beat on *every* problem. :-) Damian

AW: my int( 1..31 ) $var ?

2003-01-04 Thread Murat Ünalan
It's also far slower. Constructing a 31-element list, junctionizing it, This might well be done at compile-time. And/or, lazily. So the cost of these two steps is likely to be negligible. then testing against each element vs. 2 numeric comparisons. Yes. That's a significant cost

AW: my int( 1..31 ) $var ?

2003-01-04 Thread Murat Ünalan
my $var = 0; # or my $var = 0; # or my int $var = 0; # or my num $var = 0; # all 4 cases should print is integer print is integer if int $var == $var; This should work as a more generic method to test Integer *value*, rather than type, which IMHO is more useful (and more commonly

Re: AW: my int( 1..31 ) $var ?

2003-01-04 Thread John Williams
On Sat, 4 Jan 2003, Murat Ünalan wrote: print creditcard if $var == CreditCard( 'VISA' ); wich should do a mod10 on $var and then match a regex or something. I think one could say CreditCard( 'VISA' ) is then the property. And after reading further seeing it could be smart matched like:

Re: AW: my int( 1..31 ) $var ?

2003-01-04 Thread Damian Conway
Murat Ünalan wrote: print creditcard if $var ~~ CreditCard( 'VISA' ); Brought to a point: Properties could be also smart matched. Properties *can* be smart-matched: print creditcard if $var.prop().{CreditCard} ~~ 'VISA'; or: print creditcard if $var.prop{CreditCard} ~~ 'VISA'; or: print

AW: my int( 1..31 ) $var ?

2003-01-04 Thread Murat Ünalan
Why should you care? Perl 6 isn't going to be that strictly typed, is it? Not even optional ? Murat

Re: AW: AW: my int( 1..31 ) $var ?

2003-01-04 Thread John Williams
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

Re: AW: my int( 1..31 ) $var ?

2003-01-04 Thread Christian Renz
Now, I might be stupid, but I keep asking myself what you would need a property for in this example. To me, it totally confuses the underlying structure. When was the last time you asked an integer to identify itself as a valid credit card number? It is _not_ a property of the integer that it is