Re: Defaulting params (reprise)
Trey Harris wrote: A more practical application would be: my $foo; # Code which might or might not set $foo... $foo //= 23; # or $foo is default(23); In such a case, the Cis default just looks plain odd to me. It is. More than that, it's plain wrong. Cis properties are compile-time features. They can only be specified on declarations. Weird. C//= seems perfectly reasonable to me. To us too. That's why we chose them for parameter defaulting as well. Damian
Re: Defaulting params (reprise)
From: Trey Harris [EMAIL PROTECTED] Properties are meant to be out-of-band information; miko's suggestion would have this property setting the *value* of the variable. Ah, but my exact point is that the default *isn't* set immediately. The property is held until the sub is called. If the argument is passed, the default property is ignored. If it isn't set, only then is the default property used to set the value. That's why I don't think the property makes any sense except when used to define subroutine arguments. And then Damian said: That's why we chose them for parameter defaulting as well. Ah well. Let's see how it plays in Peoria. -Miko mail2web - Check your email from the web at http://mail2web.com/ .
Re: Defaulting params (reprise)
On Wed, Sep 04, 2002 at 04:01:50PM -0400, [EMAIL PROTECTED] wrote: It was settled a while ago that sub arguments would be defaulted like this: sub load_data ($version / /=1) {...} (The space between / and / is on purpose, my emailer has problems if they are together) I and a few others had issues with the slash-slash-equals thing, but were unable to persuade Damian, Larry, et al to change. Hopefully those problems had nothing to do with you MUA ;-) I'd like to make one more proposal for defaulting. Damian seems to like properties for arguments, how 'bout this construct: sub load_data ( $version is default(1) ) {...} It's clean, fits the existing syntax, and immediately understandable. Thoughts? So, how would you write the equivalent to this: $foo //= $a // $b // $c; Or are you proposing to *only* replace //=? Or are you proposing to *only* replace //= in subroutine declarations? What issues did you have with //=? It seems clear and concise to me. -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: Defaulting params (reprise)
From: Jonathan Scott Duff [EMAIL PROTECTED] Or are you proposing to *only* replace //=? Or are you proposing to *only* replace //= in subroutine declarations? Only augment //= in subroutine declarations, //= would also work. What issues did you have with //=? It seems clear and concise to me. I love the //= operator, but in the context of sub declarations it's confusing as the *only* way to default an argument. I still think = makes sense as an argument defaulter... but that issue's been settled for now and I'm not advancing it again. :-) -Miko mail2web - Check your email from the web at http://mail2web.com/ .
Re: Defaulting params (reprise)
On Wed, Sep 04, 2002 at 04:43:25PM -0400, [EMAIL PROTECTED] wrote: Only augment //= in subroutine declarations, //= would also work. I love the //= operator, but in the context of sub declarations it's confusing as the *only* way to default an argument. Oh. You want default() to be synonymous with //= but only in subroutine declarations. That seems a tad odd. Why not make it synonymous everywhere? my $foo is default(23); # same as ... my $foo //= 23; -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: Defaulting params (reprise)
From: Jonathan Scott Duff [EMAIL PROTECTED] Oh. You want default() to be synonymous with //= but only in subroutine declarations. That seems a tad odd. Why not make it synonymous everywhere? my $foo is default(23); # same as ... my $foo //= 23; Well, for is default to DWIM in a function call, it would almost have to not DWIM outside a function call. Why? Well, the concept (as seen through my too-human eyes) would be that the function arguments would be created and populated something like this: 1) create the variable 2) if the argument is sent, set the value of the variable using the sent value 3) else set the value using the default property. OK, that makes sense so far, but outside of a function call, I'm not sure where it would be decided that the variable was never set, and so it would never get the default value. Yes, is default could populate the variable as soon as it is created, but that seems wasteful. Is there a general rule that a property must make sense in all contexts? If Perl6 has the is named property for sub arguments, does that mean that it must also make sense outside a function... my $foo is named('bar'); (Hmm, maybe it does... you could have two variables aliased to each other. OK, bad example. Work with me here.) -Miko mail2web - Check your email from the web at http://mail2web.com/ .
Re: Defaulting params (reprise)
On Wed, Sep 04, 2002 at 05:06:32PM -0400, [EMAIL PROTECTED] wrote: Is there a general rule that a property must make sense in all contexts? Nah, I was just being distracted by work and not thinking clearly about your default() proposal. :-) -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: Defaulting params (reprise)
On Wed, Sep 04, 2002 at 03:48:41PM -0500, Jonathan Scott Duff wrote: On Wed, Sep 04, 2002 at 04:43:25PM -0400, [EMAIL PROTECTED] wrote: Only augment //= in subroutine declarations, //= would also work. I love the //= operator, but in the context of sub declarations it's confusing as the *only* way to default an argument. Oh. You want default() to be synonymous with //= but only in subroutine declarations. That seems a tad odd. Why not make it synonymous everywhere? my $foo is default(23); # same as ... my $foo //= 23; I dont see what's that meant to be achieving. Surely It's always 23. andrew -- Cancer: (June 22 - July 22) You will soon be exposed to the most rocking music ever, but due to your unrockable nature, you will remain profoundly unrocked.
Re: Defaulting params (reprise)
In a message dated Wed, 4 Sep 2002, Andrew Wilson writes: On Wed, Sep 04, 2002 at 03:48:41PM -0500, Jonathan Scott Duff wrote: On Wed, Sep 04, 2002 at 04:43:25PM -0400, [EMAIL PROTECTED] wrote: Only augment //= in subroutine declarations, //= would also work. I love the //= operator, but in the context of sub declarations it's confusing as the *only* way to default an argument. Oh. You want default() to be synonymous with //= but only in subroutine declarations. That seems a tad odd. Why not make it synonymous everywhere? my $foo is default(23); # same as ... my $foo //= 23; I dont see what's that meant to be achieving. Surely It's always 23. A more practical application would be: my $foo; # Code which might or might not set $foo... $foo //= 23; # or $foo is default(23); In such a case, the Cis default just looks plain odd to me. Properties are meant to be out-of-band information; miko's suggestion would have this property setting the *value* of the variable. Weird. C//= seems perfectly reasonable to me. Trey