Re: Defaulting params (reprise)

2002-09-05 Thread Damian Conway
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

Re: Defaulting params (reprise)

2002-09-05 Thread [EMAIL PROTECTED]
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

Re: Defaulting params (reprise)

2002-09-04 Thread Jonathan Scott Duff
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

Re: Defaulting params (reprise)

2002-09-04 Thread [EMAIL PROTECTED]
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

Re: Defaulting params (reprise)

2002-09-04 Thread Jonathan Scott Duff
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

Re: Defaulting params (reprise)

2002-09-04 Thread [EMAIL PROTECTED]
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

Re: Defaulting params (reprise)

2002-09-04 Thread Jonathan Scott Duff
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)

2002-09-04 Thread Andrew Wilson
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

Re: Defaulting params (reprise)

2002-09-04 Thread Trey Harris
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,

Re: Defaulting params

2002-04-12 Thread Aaron Sherman
On Fri, 2002-04-12 at 00:37, Melvin Smith wrote: At 04:03 PM 4/11/2002 -0400, Aaron Sherman wrote: Notice that we have two different types of defaulting here. The second argument is the file to work on, and we set it to a reasonable default if it is undefined for whatever reason. However,

Re: Defaulting params

2002-04-11 Thread Aaron Sherman
On Thu, 2002-04-11 at 00:47, Damian Conway wrote: sub load_data ($filename) { load_data($filename, 1) } sub load_data ($filename, $version) {...} Interesting. This brings goto to mind. Above, I could just assume that inlining will happen, but what about goto? Obviously: sub

Re: Defaulting params

2002-04-11 Thread Jonathan Scott Duff
On Wed, Apr 10, 2002 at 10:45:55PM -0600, Luke Palmer wrote: Indeed, and with the //= thing, you can let parameters in the middle default. Except that I haven't heard anyone say that given sub foo ($a//=1, $b//=2, $c//=3) {...} foo(5,,6); # that

Re: Defaulting params

2002-04-11 Thread Ariel Scolnicov
[Apologies to Aaron Sherman, who gets this twice due to my dunderheadedness] Aaron Sherman [EMAIL PROTECTED] writes: [...] Also, another though: sub foo($a = 1, $b, $c) { ... } In C++ at least, I think this is an error. However, it seems to me that in Perl it could be interpreted

Re: Defaulting params

2002-04-11 Thread Miko O'Sullivan
sub foo($a=1, $b, $c=3) { ... } is ambiguous: While foo(2) sets $a=1, $b=2, $c=3, it's impossible to say what foo(4,5) should do. foo(2) means that $a = 2, $b defaults to undef, $c defaults to 3 foo(4,5) means $a = 4, $b = 5, and $c defaults to 3. -Miko

Re: Defaulting params

2002-04-11 Thread Aaron Sherman
On Thu, 2002-04-11 at 09:59, Ariel Scolnicov wrote: [Apologies to Aaron Sherman, who gets this twice due to my dunderheadedness] No problem. I usually reply to the person and CC the list because some folks have filters that will make discussions easier if I'm replying to them vs. sending just

Re: Defaulting params

2002-04-11 Thread Aaron Sherman
On Thu, 2002-04-11 at 11:55, Aaron Sherman wrote: 1. The first default marks the beginning of optional parameters. 2. An optional parameter with no default will automatically default to undef. Interestingly, I just said something that I did not mean to, but it opens up an interesting avenue.

Re: Defaulting params

2002-04-11 Thread Luke Palmer
class myobj { ... int a,b,c; myobj(int aa, int bb, int cc) : a(aa), b(bb), c(cc) const {} ... }; Ummm no. Straight from Bjarne: You can't have a const constructor. You just do what you did without

Re: Defaulting params

2002-04-11 Thread Aaron Sherman
On Thu, 2002-04-11 at 12:44, Luke Palmer wrote: class myobj { ... int a,b,c; myobj(int aa, int bb, int cc) : a(aa), b(bb), c(cc) const {} ... }; Ummm no. Straight from Bjarne: You can't have a const

Re: Defaulting params

2002-04-11 Thread Piers Cawley
Aaron Sherman [EMAIL PROTECTED] writes: On Thu, 2002-04-11 at 00:47, Damian Conway wrote: sub load_data ($filename) { load_data($filename, 1) } sub load_data ($filename, $version) {...} Interesting. This brings goto to mind. Above, I could just assume that inlining will

Re: Defaulting params

2002-04-11 Thread Larry Wall
Miko O'Sullivan writes: : I think you're right that this is a valid distinction, I'm just not : sure if it's not a little too subtle and that the two different : notations won't cause confusion. : : Well, I had been hoping to appeal to the mathematical mindset of the list, : but there is a

Re: Defaulting params

2002-04-11 Thread Aaron Sherman
On Thu, 2002-04-11 at 14:34, Larry Wall wrote: Miko O'Sullivan writes: : Well, I had been hoping to appeal to the mathematical mindset of the list, : but there is a second reason for = in addition to / /=: it's simpler to : understand. I just think that the potential Perl hackers will

Re: Defaulting params

2002-04-11 Thread Melvin Smith
At 04:03 PM 4/11/2002 -0400, Aaron Sherman wrote: On Thu, 2002-04-11 at 14:34, Larry Wall wrote: Miko O'Sullivan writes: : Well, I had been hoping to appeal to the mathematical mindset of the list, : but there is a second reason for = in addition to / /=: it's simpler to : understand.

Re: Defaulting params

2002-04-10 Thread Piers Cawley
Miko O'Sullivan [EMAIL PROTECTED] writes: The current plans indicate that a subroutine's params should be defaulted like this: sub load_data ($filename ; $version / /= 1) {...} (The space between / and / is on purpose, my emailer has problems if they are together.) If that's the

Re: Defaulting params

2002-04-10 Thread Luke Palmer
On Thu, 11 Apr 2002, Piers Cawley wrote: Miko O'Sullivan [EMAIL PROTECTED] writes: The current plans indicate that a subroutine's params should be defaulted like this: sub load_data ($filename ; $version / /= 1) {...} (The space between / and / is on purpose, my emailer has

Re: Defaulting params

2002-04-10 Thread Damian Conway
Piers wrote: one could always handle the first case more explicitly by doing: sub load_data ($filename; $version) { $version = 1 if _.length 2; ... } Err...no. If you specify named parameters, you don't get _. It could be handled by overloading though: sub

Re: Defaulting params

2002-04-10 Thread Piers Cawley
Damian Conway [EMAIL PROTECTED] writes: Piers wrote: one could always handle the first case more explicitly by doing: sub load_data ($filename; $version) { $version = 1 if @_.length 2; ... } Err...no. If you specify named parameters, you don't get @_. It could be