David Whipp wrote:
$b = 7, 6, 5
b = 7, 6, 5
I understand that C's *interpretation* of the comma operator will be expunged from
Perl 6. But unless comma's *precedence* is also changing, neither of those statements
would build a list with three elements.
It seems to me that
$b = 7, 6,
Aaron Sherman wrote:
On Sat, 2002-09-21 at 06:38, Smylers wrote:
... lists now use square brackets.
I don't disagree that this is a good thing, but let's look at some
cases that might not look the way you had intended: Snip
Oh, I hadn't really intending anything. Starting from what
Luke Palmer wrote:
On 21 Sep 2002, Smylers wrote:
But because C$num _might_ be used as an array ref, the data has to
be kept around, which is wasteful.
The programmer should know whether it would or wouldn't,
Oh, I wasn't doubting that. I was just concerned that if the 'typical'
way
On Tue, 2002-09-24 at 01:46, Trey Harris wrote:
In a message dated 24 Sep 2002, Aaron Sherman writes:
This is because push is
almost certainly defined as:
sub push(@target, *@list) { ... }
That should be
sub push(@target is rw, *@list);
Well, yes, but that wasn't the
[EMAIL PROTECTED] (Aaron Sherman) writes:
say that array refs behave the same as arrays in every way *except* as
pertains to list flattening, and in that case, explicit flattening is
required, otherwise the ref is kept in the flattened array.
Another blow to regularity. :(
--
[EMAIL PROTECTED] (Aaron Sherman) writes:
If we have to resort to much magic to get these right, we're pretty much
doomed from the outset.
You have that upside-down. Because this is so fundamental, it's worth a
great deal of magic to make it seem right in as many contexts as
possible.
On Tue, Sep 24, 2002 at 11:30:57AM +0100, Simon Cozens wrote:
At any rate, I do wish we'd stop kidding ourselves that Perl 6 is at all
going to be cleaned up or regular; I bet it'll end up with more edge
cases and special exceptions than Perl 5.
Simon, Perl 6 *will* be more regular as long as
On 24 Sep 2002 05:21:37 -0400, Aaron Sherman wrote:
On Tue, 2002-09-24 at 01:46, Trey Harris wrote:
sub push(@target is rw, *@list);
Well, yes, but that wasn't the point. The C*@list will force array
flattening, thus
push @a, [1,2,3], 4;
will (according to Larry's stated
According to Trey Harris:
According to Larry,
$a = (1,2,3);
is equivalent to
$a = [1,2,3];
because they're both equivalent to
$a = scalar(1,2,3)
But that's the bit we're arguing about. If you allow
$a = (1,2)
then what about
$a = (1)
? And if someone says that I have to
In a message dated Tue, 24 Sep 2002, Chip Salzenberg writes:
According to Trey Harris:
According to Larry,
$a = (1,2,3);
is equivalent to
$a = [1,2,3];
because they're both equivalent to
$a = scalar(1,2,3)
But that's the bit we're arguing about. If you allow
$a = (1,2)
On Tue, 2002-09-24 at 10:27, Peter Haworth wrote:
On 24 Sep 2002 05:21:37 -0400, Aaron Sherman wrote:
On Tue, 2002-09-24 at 01:46, Trey Harris wrote:
sub push(@target is rw, *@list);
Well, yes, but that wasn't the point. The C*@list will force array
flattening, thus
push
At 11:07 AM -0400 9/24/02, Trey Harris wrote:
*shrug* Regardless of whether we like it, what Larry said is true unless
and until he invokes Rule 2. And unless he invokes Rule 2,
Cscalar(1,2,3) is equivalent to C[1,2,3].
Then perhaps, rather than fretting over the unpleasant consequences
of
On Tue, 2002-09-24 at 11:07, Trey Harris wrote:
In a message dated Tue, 24 Sep 2002, Chip Salzenberg writes:
then what about
$a = (1)
? And if someone says that I have to write:
$a = (1,)
then I am going on the warpath. That Way Lay Python.
I would *never* suggest
In a message dated 24 Sep 2002, Aaron Sherman writes:
That doesn't really work. Because now you introduce the case where:
$x = (1,2,3);
y = (1,2,3);
$z = [1,2,3];
push a, $x, y, $z, (1,2,3), [1,2,3];
Behaves in ways that will take hours to explain to newbies, and I
In a message dated Tue, 24 Sep 2002, Jonathan Scott Duff writes:
On Tue, Sep 24, 2002 at 11:14:04AM -0400, Aaron Sherman wrote:
Again, we're wading into the waters of over-simplification. Let's try:
sub foo1(){ my foo=(1,2,3); return foo; }
sub foo2(){ my $foo = [1,2,3];
On Tue, Sep 24, 2002 at 12:14:10PM -0400, Trey Harris wrote:
In a message dated Tue, 24 Sep 2002, Jonathan Scott Duff writes:
On Tue, Sep 24, 2002 at 11:14:04AM -0400, Aaron Sherman wrote:
Again, we're wading into the waters of over-simplification. Let's try:
sub foo1(){ my
In a message dated Tue, 24 Sep 2002, Chip Salzenberg writes:
then what about
$a = (1)
? And if someone says that I have to write:
$a = (1,)
then I am going on the warpath. That Way Lay Python.
You _can_ write that, but you don't _have_ to. [1], (1),
It seems that the fundamental problem is the dichotomy between
a scalar, and a list of 1 elem. Thus, we want
$a = 7
to DWIM, whether I mean a list, or a scalar. Seems to me that
the best way to solve a dichotomy is to declare it to not to
be one: a scalar *IS* a list of one element. The only
On Tue, Sep 24, 2002 at 11:47:16AM -0700, David Whipp wrote:
It seems that the fundamental problem is the dichotomy between
a scalar, and a list of 1 elem. Thus, we want
$a = 7
to DWIM, whether I mean a list, or a scalar. Seems to me that
the best way to solve a dichotomy is to declare
On Tue, 2002-09-24 at 14:47, David Whipp wrote:
It seems that the fundamental problem is the dichotomy between
a scalar, and a list of 1 elem. Thus, we want
After the first couple of messages, that was really no longer *my*
concern, but I can't speak for others. My concern was mostly that
2. Scalar assignment.
my $a;# 1.
$a = X;
my $a;# 3.
($a) = X;
These should all do the same thing, regardless of X.
Consider:
$a = (1);
and
($a) = (1);
5. Assignment to arrays and lists.
$a = (1, 2, 3); # Same as Perl 5's $a = [1,2,3];
$a = (1)
In a message dated Tue, 24 Sep 2002, Mike Lambert writes:
Consider:
$a = (1);
and
($a) = (1);
Yes? They both do the same thing--set $a to 1. It looks like the bottom
one is a list assigned to a list, but that might be optimized out, as it
doesn't matter.
5. Assignment to arrays and
From: Jonathan Scott Duff
$b = 7, 6, 5
b = 7, 6, 5
Again, both create identical objects, under different
interfaces. But now we have a problem with +$b: what should
this mean? To be consistant with +$a (above), I would
suggest that it simply returns the sum of its elements
On Tue, 24 Sep 2002, Mike Lambert wrote:
$a = (1, 2, 3); # Same as Perl 5's $a = [1,2,3];
$a = (1) should then do $a = [1], according to the above.
This implies that:
($a) = (1) implies that $a is [1], something I don't particularly agree
with.
You may be missing the change in the
On Sat, 21 Sep 2002 16:33:31 -0600 (MDT), Luke Palmer said:
You know, the idea that square brackets are the only things that can
make lists is starting to really appeal to me. Similar for squiggles
and hashes. I don't know how many times in my early Perl5 days I did
this:
Since we now
[EMAIL PROTECTED] (Luke Palmer) writes:
Since we now have an explicit flattening operator (unary *), there's no
need to differentiate between a real list and a reference to one.
What context does push impute on its operands?
If
push @a, [1,2,3,4];
and
push @a, 1,2,3,4;
are going to
On Sat, 2002-09-21 at 06:38, Smylers wrote:
So if the difference between lists with parens and anon arrays with
square brackets is going away, it may make sense to standardize on the
latter rather than the former. In other words, lists now use square
brackets.
That frees up parens for
On 23 Sep 2002, Simon Cozens wrote:
[EMAIL PROTECTED] (Luke Palmer) writes:
Since we now have an explicit flattening operator (unary *), there's no
need to differentiate between a real list and a reference to one.
What context does push impute on its operands?
If
push @a,
I think this discussion has gotten out of hand, and I hope that Larry,
Damian or Allison will grace us with a resolution soon. :-)
May I suggest that we start with some DWIMmy examples and try to arrive at
a mechanism that will make them all DWIM? Here are my opinions, feel free
to shoot them
[EMAIL PROTECTED] (Luke Palmer) writes:
push @a: [1,2,3,4];
pushes an array ref onto @a.
push @a: *[1,2,3,4];
pushes 1, 2, 3, and 4 onto @a (as it would without the * and []).
Remind me which language this is supposed to be, again?
--
Life sucks, but it's better than the
[EMAIL PROTECTED] (Trey Harris) writes:
May I suggest that we start with some DWIMmy examples
Sam sat on the ground and put his head in his hands. 'I wish I had
never come here, and I don't want to see no more magic,' he said, and
fell silent.
--
I hooked up my accelerator pedal in my car to
On Mon, 23 Sep 2002, Jonathan Scott Duff wrote:
On Mon, Sep 23, 2002 at 04:58:55PM -0400, Trey Harris wrote:
for (1,(a,b,c),3 { ... }
and
for 1,(a,b,c),3 { ... }
Now that I've ventured away from DWIMs and more into WIHDTEMs (What In
Hell Does This Expression Mean), is the
On 24 Sep 2002, Simon Cozens wrote:
[EMAIL PROTECTED] (Luke Palmer) writes:
push @a: [1,2,3,4];
pushes an array ref onto @a.
push @a: *[1,2,3,4];
pushes 1, 2, 3, and 4 onto @a (as it would without the * and []).
Remind me which language this is supposed to be, again?
In a message dated Mon, 23 Sep 2002, Luke Palmer writes:
Y'all have it backwards.
[1,*[2,[3,4,5]],6] # [1,2,[3,4,5],6]
[1,*[2,*[3,4,5]],6] # [1,2,3,4,5,6]
Flat flattens outwards, not inwards.
Ah. *slaps head* of course. That makes much more sense.
On Mon, 2002-09-23 at 16:58, Trey Harris wrote:
4. Numeric value.
The progression spoken about at great length previously:
+()# == 0
+(0) # == WHAT? 0? 1?
+(0,1) # == 2
+(0,1,2) # == 3
+(0,1,2,3) # == 4
+(0,...,n) # == n + 1
is largely
On Mon, 2002-09-23 at 15:48, Luke Palmer wrote:
On 23 Sep 2002, Simon Cozens wrote:
[EMAIL PROTECTED] (Luke Palmer) writes:
Since we now have an explicit flattening operator (unary *), there's no
need to differentiate between a real list and a reference to one.
What context does
Replying to myself to clear a few things up...
In a message dated Mon, 23 Sep 2002, Trey Harris writes:
2. Scalar assignment.
my $a;# 1.
$a = X;
my $a;# 2.
$a = X;
my $a;# 3.
($a) = X;
my($a) = X; # 4.
my($a) = (X); # 5.
In a message dated 24 Sep 2002, Aaron Sherman writes:
Grrr... I want that to work, really I do, but since, as Larry has
pointed out, there's no functional difference between an array ref and
an array in Perl 6, they would be the same. This is because push is
almost certainly defined as:
On Sat, 2002-09-21 at 06:18, Smylers wrote:
$num = @massive;
C$num becomes a reference to C@massive, but in a numeric context it
will evaluate to the number of elements in that array.
But in most cases, you would never do this. You would do something like
my int $num =
In a message dated 24 Sep 2002, Aaron Sherman writes:
This is because push is
almost certainly defined as:
sub push(target, *@list) { ... }
That should be
sub push(target is rw, *@list);
but otherwise I think that's right.
Now, implementation in Perl 6 (though I assume it's
On Mon, 23 Sep 2002, Trey Harris wrote:
So then, I think if there's just some clarification about how one-tuples
are formed, I think everything I wrote in my earlier mail can DWIM
correctly. There seems to be no magic here, quotations from LoTR to the
contrary. :-)
Your post was very
On Sun, 2002-09-22 at 08:07, Simon Cozens wrote:
[EMAIL PROTECTED] (Jonathan Scott Duff) writes:
Why can't perl be smart enough to figure out what we mean?
We're talking about lists, the second most fundamental data structure
in the language.
If we have to resort to much magic to get
[EMAIL PROTECTED] (Jonathan Scott Duff) writes:
Why can't perl be smart enough to figure out what we mean?
We're talking about lists, the second most fundamental data structure
in the language.
If we have to resort to much magic to get these right, we're pretty much
doomed from the outset.
--
[EMAIL PROTECTED] (Smylers) writes:
Does that matter? This example is fairly contrived, and anybody
actually concerned about this can always use:
$num = @massive.length;
I'd be in favour of forcing people to say this if they want the length
of the array.
But then, it might be that what
Chip Salzenberg [EMAIL PROTECTED] writes:
According to David Whipp:
(7,8,9) == 3 # true
(7,8) == 2 # true
(7) == 1 # false
() == 0 # true?
Hell, yes, why didn't I think of that? This is exactly the same
problem that afflicts Python's tuple syntax!
various 1-uple
At 10:52 AM -0500 9/21/02, Jonathan Scott Duff wrote:
So, you expect 7.pow(2) to work? I'd expect it to be an error (this
isn't python after all).
Sure, why not? I mean, we already use methods on integers all the
time--what do you thin 12.5 is anyway, other than calling the 5
method on the
[EMAIL PROTECTED] (Markus Laire) writes:
How do you do C ($a + $b) * $c if parentheses are forbidden for
mathematical expressions?
I thought that , was actually the list constructor, much as = is the
pair constructor. (And hence
a = 1, b = 2
would be a list of pairs.)
Of course,
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
Why can't perl be smart enough to figure out what we mean? Something
along these lines:
(7) # list context
(3+4) # numeric context (there's a numeric operator in there)
(3+4,5) # list context (comma trumps the numeric
According to John Williams:
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
(7,) is an abomination. It's one of python's misfeatures that annoys
me the most.
Of course, _requiring_ the comma is bad [...]
Well, I don't know about Jonathan, but requiring the comma is exactly
what Python
Luke Palmer wrote:
my v = $( func() );
Would provide scalar context. But then assign it to a list...
In the course of reading that I developed a concern about memory usage
when trying to find the size of arrays. As I understand it the Perl 5
syntax for discovering the number of
Tanton Gibbs wrote:
(7) == 7
why? Otherwise, we couldn't use parens for mathematical expressions
Evil But as Luke Palmer pointed about above, this syntax would make
square brackets redundant, so we could now use those unambiguously for
overriding mathematical precedence ... /Evil
(Sorry
On Fri, Sep 20, 2002 at 09:46:58PM -0600, John Williams wrote:
On Fri, 20 Sep 2002, Jonathan Scott Duff wrote:
But I cannot tell whether (7) is list context or numeric context,
Nope, you can't tell without the surrounding context:
(7) + 0;# numeric
$a = (7); #
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
I can't tell whether (7).length is asking for the length
of 7 or the length of a list, but I would be badly surprised if
(3+4).pow(2) returned 1 instead of 49.
So, you expect 7.pow(2) to work? I'd expect it to be an error (this
isn't
On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote:
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
I can't tell whether (7).length is asking for the length
of 7 or the length of a list, but I would be badly surprised if
(3+4).pow(2) returned 1 instead of 49.
So, you
On 21 Sep 2002, Smylers wrote:
Luke Palmer wrote:
my v = $( func() );
Would provide scalar context. But then assign it to a list...
In the course of reading that I developed a concern about memory usage
when trying to find the size of arrays. As I understand it the Perl 5
On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote:
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
Anyway, (7) or (3+4) should yield a number, not a list, because
otherwise every math expression will break.
Why can't perl be smart enough to figure out what we mean?
On Sun, 22 Sep 2002, Markus Laire wrote:
On Sat, Sep 21, 2002 at 11:36:49AM -0600, John Williams wrote:
On Sat, 21 Sep 2002, Jonathan Scott Duff wrote:
Anyway, (7) or (3+4) should yield a number, not a list, because
otherwise every math expression will break.
Why can't perl
Luke Palmer wrote:
On Sun, 22 Sep 2002, Markus Laire wrote:
You know, the idea that square brackets are the only things that can make
lists is starting to really appeal to me. Similar for squiggles and
snip
So parens really do provide grouping, not list constructing. Thus, this
can stay:
SC == Simon Cozens [EMAIL PROTECTED] writes:
SC raiddev /dev/md0
SC raid-level 5
SC option value
SC option value
SC ...
SC device /dev/sde1
SC raid-disk 0
i have some
SC == Simon Cozens [EMAIL PROTECTED] writes:
SC rule comm_eol { sp* comment? sp* \n };
aren't those sp*'s redundant? the first is overlapping with the one at
the beginning of comment.
SC But comment only matches if there *is* a comment, and there may not
SC be, so I want to
[EMAIL PROTECTED] (Uri Guttman) writes:
actually i just had another thought. you don't need any of the $foo :=
stuff as the match tree will have it all for you.
Yes, but it's nice to be able to access the captured things by
name. Or should I be saying things like
rule raiddev { comment*
SC == Simon Cozens [EMAIL PROTECTED] writes:
SC [EMAIL PROTECTED] (Uri Guttman) writes:
actually i just had another thought. you don't need any of the $foo :=
stuff as the match tree will have it all for you.
SC Yes, but it's nice to be able to access the captured things by
SC
On 20 Sep 2002, Simon Cozens wrote:
: their names. also if you use a scalar to grab something which is in a
: quantified outer rule what is put in the var? a ref to a list of the
: grabbed things?
:
: *nod* Something I'd like to know.
Yes, in fact any list forced into scalar context will
On Fri, 2002-09-20 at 04:14, Larry Wall wrote:
On 20 Sep 2002, Simon Cozens wrote:
: their names. also if you use a scalar to grab something which is in a
: quantified outer rule what is put in the var? a ref to a list of the
: grabbed things?
:
: *nod* Something I'd like to know.
On 20 Sep 2002, Aaron Sherman wrote:
: Is that any list as oppopsed to any array? Or is that arrayref in a
: numeric context the length of the array? In other words does this do
: what I think I think it does?
:
: $shouldbe3 = (1,2,3) + 0;
It's 3, though not for the reason a Perl 5
On Fri, 2002-09-20 at 10:39, Larry Wall wrote:
On 20 Sep 2002, Aaron Sherman wrote:
: Is that any list as oppopsed to any array? Or is that arrayref in a
: numeric context the length of the array? In other words does this do
: what I think I think it does?
:
: $shouldbe3 = (1,2,3) + 0;
On Fri, 20 Sep 2002, Larry Wall wrote:
Yes, in fact any list forced into scalar context will make a ref in Perl 6:
$arrayref = (1,2,3);
That would seem to obviate the need for brackets to define array
references. Is there any case where [1,2,3] would be needed instead of
(1,2,3)?
Also,
On Fri, 20 Sep 2002, John Williams wrote:
: On Fri, 20 Sep 2002, Larry Wall wrote:
:
: Yes, in fact any list forced into scalar context will make a ref in Perl 6:
:
: $arrayref = (1,2,3);
:
: That would seem to obviate the need for brackets to define array
: references. Is there any
On Fri, 20 Sep 2002, Larry Wall wrote:
On Fri, 20 Sep 2002, John Williams wrote:
: On Fri, 20 Sep 2002, Larry Wall wrote:
:
: Yes, in fact any list forced into scalar context will make a ref in Perl 6:
:
: $arrayref = (1,2,3);
:
: That would seem to obviate the need for brackets
John Williams wrote:
On Fri, 20 Sep 2002, Larry Wall wrote:
On Fri, 20 Sep 2002, John Williams wrote:
: On Fri, 20 Sep 2002, Larry Wall wrote:
:
: Yes, in fact any list forced into scalar context will make a ref in Perl 6:
:
: $arrayref = (1,2,3);
:
: That would seem to obviate the
I was just thinking that $((1,2,3)) is also the same as [1,2,3],
and shorter than scalar(1,2,3).
I wonder if you can't just use $(1, 2, 3) to the same effect.
I think you can. I was under the impression that the C comma was dying,
so that would have to make a list or err.
Also, I
According to Luke Palmer:
I think to get Perl5 behavioueaur :), you do this:
my @flatL = ( *(1a, 2a), *(1b, 2b) );
Geez, I hope not, because that would imply that in
my @v = ( func() );
that func is called in a scalar context.
--
Chip Salzenberg - a.k.a. -[EMAIL
Larry wrote:
: $shouldbe3 = (1,2,3) + 0;
It's 3, though not for the reason a Perl 5 programmer would think.
(In Perl 6 it's the length of the anonymous array, not the
last value.)
This kind of clever magic always makes me nervous:
it introduces subtle bug potentials.
(7,8,9) == 3 #
According to David Whipp:
(7,8,9) == 3 # true
(7,8) == 2 # true
(7) == 1 # false
() == 0 # true?
Hell, yes, why didn't I think of that? This is exactly the same
problem that afflicts Python's tuple syntax!
Larry, I strongly suggest that making () act in any way like []
On Fri, 20 Sep 2002, Chip Salzenberg wrote:
According to Luke Palmer:
I think to get Perl5 behavioueaur :), you do this:
my flatL = ( *(1a, 2a), *(1b, 2b) );
Geez, I hope not, because that would imply that in
my v = ( func() );
that func is called in a scalar context.
On Fri, 20 Sep 2002, David Whipp wrote:
Larry wrote:
: $shouldbe3 = (1,2,3) + 0;
It's 3, though not for the reason a Perl 5 programmer would think.
(In Perl 6 it's the length of the anonymous array, not the
last value.)
This kind of clever magic always makes me nervous:
it
This kind of clever magic always makes me nervous:
it introduces subtle bug potentials.
(7,8,9) == 3 # true
(7,8) == 2 # true
(7) == 1 # false
() == 0 # true?
I believe the last two cases should be:
(7,)== 1
(,) == 0
Because its the perl6
According to John Williams:
I believe the last two cases should be:
(7,)== 1
(,) == 0
Gack! It's Python's tuple syntax! Run away! Run away!
Seriously, having actually programmed Python for money (no smiley --
it was NOT fun), I can say that this syntactical hack would be a
On Fri, Sep 20, 2002 at 09:02:52PM -0600, John Williams wrote:
On Fri, 20 Sep 2002, Tanton Gibbs wrote:
If this is the case, then can you also have:
(,7)
What is its length?
Hmm, it's a syntax error in perl5.
I'd advocate it continuing to be a syntax error in perl 6.
Maybe ()
On Fri, Sep 20, 2002 at 02:17:42PM -0700, David Whipp wrote:
Larry wrote:
: $shouldbe3 = (1,2,3) + 0;
It's 3, though not for the reason a Perl 5 programmer would think.
(In Perl 6 it's the length of the anonymous array, not the
last value.)
This kind of clever magic always makes
This kind of clever magic always makes me nervous:
it introduces subtle bug potentials.
(7,8,9) == 3 # true
(7,8) == 2 # true
(7) == 1 # false
Why is this one false? I'd expect it to be true just as the others.
(7) == 7
why? Otherwise, we couldn't use parens for
On Fri, 20 Sep 2002, Jonathan Scott Duff wrote:
But I cannot tell whether (7) is list context or numeric context,
Nope, you can't tell without the surrounding context:
(7) + 0;# numeric
$a = (7); # list
(7) == 1; # boolean (same as (7).length == 1)
82 matches
Mail list logo