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
Attriel wrote:
Well, in general I think it would be good to have some mechanism for
determining the type of the data rather than the type of a
representation of the contained value.
Why? One of the nice things about Perl is that coercian takes care of
these kind of things so that you don't
Luke Palmer wrote:
From: Joe Gottman [EMAIL PROTECTED]
Date: Fri, 3 Jan 2003 22:25:16 -0500
JG == Joe Gottman [EMAIL PROTECTED] writes:
JG Speaking of which, is there a run-time test to check if a variable
JG is of
JG integral type? Something like
JG print date if ($var
[EMAIL PROTECTED] (Joe Gottman) writes:
In the above case int($var) == $var returns true when I would want it to
return false.
Why should you care? Perl 6 isn't going to be that strictly typed, is it?
--
I wish my keyboard had a SMITE key
-- J-P Stacey
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
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
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:
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
Why should you care? Perl 6 isn't going to be that strictly
typed, is it?
Not even optional ?
Murat
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
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
print date if $var.isa(int);
print date if isa $var: int;
print date if $var ~~ int;
Those should all work. IMO the first reads the best. That will also
work for CInts, as CInt is a subclass of Cint (I think).
These only determine if $var is of type int or Int. However:
my
Murat Ünalan wrote:
print date if $var is int( 1..31 );
I don't think that the type needs to be specified here, especially if
the variable has already been declared to be of the required type, so a
junction should be sufficient:
print date if $var == any(1 .. 31);
Smylers
On Friday, January 3, 2003, at 08:55 AM, Smylers wrote:
Murat Ünalan wrote:
print date if $var is int( 1..31 );
I don't think that the type needs to be specified here, especially if
the variable has already been declared to be of the required type, so a
junction should be sufficient:
On Friday, January 3, 2003, at 12:00 PM, Chris Dutton wrote:
print date if 1..31 given $var;
Except that this would always be true. Nevermind, I'm an idiot.
--- Smylers [EMAIL PROTECTED] wrote:
Murat Ünalan wrote:
print date if $var is int( 1..31 );
I don't think that the type needs to be specified here, especially if
the variable has already been declared to be of the required type, so a
junction should be sufficient:
print date if
On Fri, Jan 03, 2003 at 10:58:49AM -0800, Mr. Nobody wrote:
--- Smylers [EMAIL PROTECTED] wrote:
junction should be sufficient:
print date if $var == any(1 .. 31);
Superpositions in the core? You're kidding, right?
What's wrong with if 1 = $var = 31?
My understanding was that
Date: Fri, 3 Jan 2003 12:06:24 -0500
From: Chris Dutton [EMAIL PROTECTED]
On Friday, January 3, 2003, at 12:00 PM, Chris Dutton wrote:
print date if 1..31 given $var;
Except that this would always be true. Nevermind, I'm an idiot.
You're not such an idiot. You just got one word
Chris Dutton wrote:
On Friday, January 3, 2003, at 08:55 AM, Smylers wrote:
Murat Ünalan wrote:
print date if $var is int( 1..31 );
print date if $var == any(1 .. 31);
I was under the impression the smart match operator would cover that
implicitly.
Ah, yes; of course it
David Storrs wrote:
On Fri, Jan 03, 2003 at 10:58:49AM -0800, Mr. Nobody wrote:
--- Smylers [EMAIL PROTECTED] wrote:
junction should be sufficient:
print date if $var == any(1 .. 31);
Superpositions in the core? You're kidding, right?
Yeah, somehow they just slipped right
--- Smylers [EMAIL PROTECTED] wrote:
David Storrs wrote:
On Fri, Jan 03, 2003 at 10:58:49AM -0800, Mr. Nobody wrote:
--- Smylers [EMAIL PROTECTED] wrote:
junction should be sufficient:
print date if $var == any(1 .. 31);
Superpositions in the core? You're
[EMAIL PROTECTED] (Mr. Nobody) writes:
I looked through the p6l archives, there really wasn't much discussion about
it.
http://groups.google.com/groups?q=superpositions+group%3Aperl.perl6.language
finds 141 articles.
--
An ASCII character walks into a bar and orders a double. Having a bad
Various folks wrote:
Superpositions in the core? You're kidding, right?
Nope. They're in (this week at least!)
What's wrong with if 1 = $var = 31?
...nothing. If you like it, by all means use it. But, (1) TIMTOWTDI,
(2) Smyler's version is more visually concise (although, granted, it
- Original Message -
From: Mr. Nobody [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, January 03, 2003 1:58 PM
Subject: Re: my int( 1..31 ) $var ?
--- Smylers [EMAIL PROTECTED] wrote:
Murat Ünalan wrote:
print date if $var is int( 1..31 );
I don't think
JG == Joe Gottman [EMAIL PROTECTED] writes:
JG Speaking of which, is there a run-time test to check if a variable is of
JG integral type? Something like
JG print date if ($var is int) (1 = $var = 31);
the old standby is:
int( $var ) == $var
uri
--
Uri Guttman --
- Original Message -
From: Uri Guttman [EMAIL PROTECTED]
To: Joe Gottman [EMAIL PROTECTED]
Cc: Perl6 [EMAIL PROTECTED]
Sent: Friday, January 03, 2003 10:06 PM
Subject: Re: my int( 1..31 ) $var ?
JG == Joe Gottman [EMAIL PROTECTED] writes:
JG Speaking of which, is there a run
26 matches
Mail list logo