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
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 C just looks plain odd to me.
It is. More than that, it's plain wrong. C properties are
compil
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 //= oper
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
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]
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 i
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 synon
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 concis
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
Melvin Smith wrote:
> So we have undef and reallyundef? :)
Seems reasonable, given that we have c and c.
How about:
sub foo ( $a is optional )
{
if exists($a) { ... }
elsif defined($a) { ... }
else { ... }
}
Dave.
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. Howev
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
> > : un
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 un
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
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
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 ha
> 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 w
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 avenu
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
>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
[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 inte
On Thu, 2002-04-11 at 09:36, Jonathan Scott Duff wrote:
> 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, $
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
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:
s
> 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 second reason for = in addition to /
> Ooh. Multiple dispatch is definitely in then?
Not definite yet. That was a subjunctive "could". ;-)
But I'm very hopeful, since it's hard to user-implement things like
C unless you can give a subroutine several distinct signatures.
Damian
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 g
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:
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 e
"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
30 matches
Mail list logo