Damian Conway [EMAIL PROTECTED] writes:
Dave Whipp wrote:
OK, I've assimilated all that (though it still feels wrong). I think you are
saying that of the following, the 4th is an error.
my @d = @x but Foo; # error: no values involved in this assignment
Correct. Although presumably this:
Damian Conway [EMAIL PROTECTED] writes:
This may sound like a silly idea
It's been suggested previously.
Has anyone considered removing with the syntactic distinction between
numeric and string indexing -- that is, between array and hash lookup?
Yes. We rejected the idea.
In
ECMAscript already tried this.
Bad idea.
If your hash keys happen to look like large numbers (e.g. you
have 7-digit product codes) as soon as you store one of them, it says:
Oh, this looks like a number, so we'll store it like an array and
happily creates a million empty array entries for you.
Sure. But then is this:
$ref[$key]
an array or hash look-up???
Decided at runtime?
Doesn't help if $ref refers to a type that has both hash-like and array-like
accessability. And that will be very common, since all Perl 6 regexes return
such objects.
Damian
At 8:46 AM + 1/28/03, Piers Cawley wrote:
Bugger. I was hoping that Perl 6 was going to make a Pixie like Object
database easier to write; looks like I'm wrong. One of the things
Pixie does is to attach its control data by magic to the object itself
(rather than any particular variable
At 8:47 AM + 1/28/03, Piers Cawley wrote:
Damian Conway [EMAIL PROTECTED] writes:
Sure. But then is this:
$ref[$key]
an array or hash look-up???
Decided at runtime?
How? People use strings as array indices and ints/floats as hash
indices, and count on autoconversion to Make It
Piers Cawley wrote:
Bugger. I was hoping that Perl 6 was going to make a Pixie like Object
database easier to write; looks like I'm wrong. One of the things
Pixie does is to attach its control data by magic to the object itself
(rather than any particular variable pointing to it). This lets us
--- Dan Sugalski [EMAIL PROTECTED] wrote:
At 8:47 AM + 1/28/03, Piers Cawley wrote:
Damian Conway [EMAIL PROTECTED] writes:
Sure. But then is this:
$ref[$key]
an array or hash look-up???
Decided at runtime?
How? People use strings as array indices and ints/floats as
Dan Sugalski [EMAIL PROTECTED] writes:
At 8:46 AM + 1/28/03, Piers Cawley wrote:
Bugger. I was hoping that Perl 6 was going to make a Pixie like Object
database easier to write; looks like I'm wrong. One of the things
Pixie does is to attach its control data by magic to the object itself
Dan Sugalski [EMAIL PROTECTED] writes:
At 8:47 AM + 1/28/03, Piers Cawley wrote:
Damian Conway [EMAIL PROTECTED] writes:
Sure. But then is this:
$ref[$key]
an array or hash look-up???
Decided at runtime?
How? People use strings as array indices and ints/floats as hash
Damian Conway [EMAIL PROTECTED] writes:
Piers Cawley wrote:
Bugger. I was hoping that Perl 6 was going to make a Pixie like Object
database easier to write; looks like I'm wrong. One of the things
Pixie does is to attach its control data by magic to the object itself
(rather than any
OK, here are the answers so far -- or more accurately, strawman
interpretations of those answers that should be objected to if they're
wrong.
1) Edge cases in array indexing:
my int @a = (1,2,3);
@a[0] # 1
@a[1] # 2
@a[2] # 3
@a[3] # undef
At 10:13 AM -0800 1/28/03, Michael Lazzaro wrote:
OK, here are the answers so far -- or more accurately, strawman
interpretations of those answers that should be objected to if
they're wrong.
I think some of this is incorrect which, because Damian thinks
otherwise, will need some hashing out
On Tuesday, January 28, 2003, at 10:20 AM, Dan Sugalski wrote:
At 10:13 AM -0800 1/28/03, Michael Lazzaro wrote:
1) Edge cases in array indexing:
my int @a = (1,2,3);
@a[3] # undef (warning: index out-of-bounds)
Or a real 0, since you said @a can only return integers.
On Tue, 28 Jan 2003, Dan Sugalski wrote:
At 10:13 AM -0800 1/28/03, Michael Lazzaro wrote:
@a[ Inf ] # undef (warning: can't use Inf as array index)
I'd throw an exception here.
@a[-4]# undef (warning: index out-of-bounds)
@a[-Inf] # undef (warning:
There has been discussion of allowing a default value for array cells
-- that is, one aside from Cundef or whatever the type-specific
default is. Questions, in order of increased evilness:
1) What's the final decided syntax? Two possibilities:
my @a is Array( default = 'foo' ); #
On Tue, Jan 28, 2003 at 11:15:26AM -0800, Michael Lazzaro wrote:
2) Assume the default value is a simple value, e.g. 'foo'.
my @a is Array( default = 'foo' );
@a[5] = 'bar';
@a[4]; # 'foo'
@a[5]; # 'bar'
@a[6]; # 'foo'
@a[-1];# 'bar'
--- Damian Conway [EMAIL PROTECTED] wrote:
[*] People, we just *have* to find better names for these things!
I'd suggest we henceforth call them value properties (for
Cbut) and referent properties (for Cis).
Hmm. According to this, Creturn 0 is true; would therefore be a
Michael Lazzaro said:
There has been discussion of allowing a default value for array cells
-- that is, one aside from Cundef or whatever the type-specific
default is. Questions, in order of increased evilness:
1 and 2 seem fine to me.
2a) When a cell is explicitly re-undefined, does the
--- Michael Lazzaro [EMAIL PROTECTED] wrote:
1) What's the final decided syntax? Two possibilities:
my @a is Array( default = 'foo' ); # attrib?
my @a is default('foo');# property?
Since we want arrays (lowercase) to support them, too, it should be a
property.
Michael Lazzaro wrote:
OK, here are the answers so far -- or more accurately, strawman
interpretations of those answers that should be objected to if they're
wrong.
1) Edge cases in array indexing:
my int @a = (1,2,3);
@a[0] # 1
@a[1] # 2
@a[2] # 3
--- Austin Hastings [EMAIL PROTECTED] wrote:
No, undef. OTOH, deleting @a[1] would reset it to default.
Ere someone flames my for using a hash keyword in an array context:
s/deleting/absquatulating (e.g., via pop, shift, or splice)/
=Austin
Corrected in accordance with design team member feedback. These should
be solid, now. Thanks much for the responses.
1) Edge cases in array indexing:
my @a = (1,2,3);
@a[0] # 1
@a[1] # 2
@a[2] # 3
@a[3] # def (warning: index
I think this debate is easier if you think of defaults as overriding and
auto-vivification method on a container.
On Tue, 2003-01-28 at 14:47, Paul Johnson wrote:
Michael Lazzaro said:
2a) When a cell is explicitly re-undefined, does the default value take
effect?
my @a is Array(
Austin Hastings wrote:
--- Austin Hastings [EMAIL PROTECTED] wrote:
No, undef. OTOH, deleting @a[1] would reset it to default.
Ere someone flames my for using a hash keyword in an array context:
s/deleting/absquatulating (e.g., via pop, shift, or splice)/
Unfortunately, I don't think we
On Tue, Jan 28, 2003 at 09:17:36AM -0800, Damian Conway wrote:
Errno. That's rather the whole point of Cbut properties [*].
[*] People, we just *have* to find better names for these things!
I'd suggest we henceforth call them value properties (for Cbut)
and referent properties
On Mon, Jan 27, 2003 at 01:02:28PM -0800, Austin Hastings wrote:
--- Nicholas Clark [EMAIL PROTECTED] wrote:
On Mon, Jan 27, 2003 at 11:00:17AM -0800, Michael Lazzaro wrote:
locked = 1, # read-only, can't store new values
There was a discussion on p5p about
On Tue, Jan 28, 2003 at 12:30:41PM -0800, Austin Hastings wrote:
--- Michael Lazzaro [EMAIL PROTECTED] wrote:
my int @a is Array( default = 5 );
@a[0] = undef;
This should cause a blip of some kind. If storing an explicit undef (as
opposed to undef but 0 or C$v = undef;
On Tue, 2003-01-28 at 11:49, Dan Sugalski wrote:
At 8:47 AM + 1/28/03, Piers Cawley wrote:
Damian Conway [EMAIL PROTECTED] writes:
Sure. But then is this:
$ref[$key]
an array or hash look-up???
Decided at runtime?
How? People use strings as array indices and ints/floats
Michael Lazzaro wrote:
Where def is whatever the type-specific
...or user specified...
default is, typically Cundef, C0, or C''.
Damian
Austin Hastings wrote:
Another question: If you ask for a value and get it, does the array
grow? Or does that happen only on assignment? (
Arrays (or hashes) don't grow on reading - never.
And another anser from current low level (list.c classes/Array.pmc)
*Return value
*
On Tue, 2003-01-28 at 16:23, Leopold Toetsch wrote:
Austin Hastings wrote:
Another question: If you ask for a value and get it, does the array
grow? Or does that happen only on assignment? (
Arrays (or hashes) don't grow on reading - never.
Never say never. You're correct for pure
At 4:17 PM -0500 1/28/03, Aaron Sherman wrote:
Now the question becomes, do you WANT them
for readability?
Given that Larry's answer has been a resounding yes all along, the
technical reasons (Which are, themselves, sufficient) are pretty
irrelevant.
--
On Tuesday, January 28, 2003, at 01:14 PM, Damian Conway wrote:
I'm not compelled by the counter-argument that this makes it
impossible to store an Cundef in an array with a default. Because
the whole point of an array having a default is to prevent those nasty
out-of-range Cundefs from
On Tue, 2003-01-28 at 16:34, Dan Sugalski wrote:
At 4:17 PM -0500 1/28/03, Aaron Sherman wrote:
Now the question becomes, do you WANT them
for readability?
Given that Larry's answer has been a resounding yes all along,
I'm not sure that this specific case was brought up. I remember Larry
On Tuesday, January 28, 2003, at 01:01 PM, Nicholas Clark wrote:
On Tue, Jan 28, 2003 at 12:30:41PM -0800, Austin Hastings wrote:
--- Michael Lazzaro [EMAIL PROTECTED] wrote:
my int @a is Array( default = 5 );
@a[0] = undef;
This should cause a blip of some kind. If storing an
At 5:07 PM -0500 1/28/03, Aaron Sherman wrote:
On Tue, 2003-01-28 at 16:34, Dan Sugalski wrote:
At 4:17 PM -0500 1/28/03, Aaron Sherman wrote:
Now the question becomes, do you WANT them
for readability?
Given that Larry's answer has been a resounding yes all along,
I'm not sure that
--- Damian Conway [EMAIL PROTECTED] wrote:
Austin Hastings wrote:
--- Austin Hastings [EMAIL PROTECTED] wrote:
No, undef. OTOH, deleting @a[1] would reset it to default.
Ere someone flames my for using a hash keyword in an array context:
s/deleting/absquatulating (e.g., via
Michael Lazzaro wrote:
2) There is NO platform-dependent maximum array size. If it's not a
sparse array, you'll run out of memory long before you run out of
indexes, but using bigints as indexes for sparse arrays is OK.
Current: array size is limited to $arch's +INTVAL (2^31-1 / 2^63-1).
Austin Hastings wrote:
--- Austin Hastings [EMAIL PROTECTED] wrote:
No, undef. OTOH, deleting @a[1] would reset it to default.
Ere someone flames my for using a hash keyword in an array context:
s/deleting/absquatulating (e.g., via pop, shift, or splice)/
What's wrong with Cdelete in
--- Michael Lazzaro [EMAIL PROTECTED] wrote:
On Tuesday, January 28, 2003, at 01:01 PM, Nicholas Clark wrote:
On Tue, Jan 28, 2003 at 12:30:41PM -0800, Austin Hastings wrote:
--- Michael Lazzaro [EMAIL PROTECTED] wrote:
my int @a is Array( default = 5 );
@a[0] = undef;
On Tue, Jan 28, 2003 at 02:13:22PM -0800, Michael Lazzaro wrote:
Hmm. I don't have a strong preference either way, but I'm not sure why
(given Cmy int @a):
@a[ undef ]
Cundef should be autoconverted to 0 with warning, but in:
@a[0] = undef;
Cundef should _not_ be
Austin Hastings wrote:
--- Damian Conway [EMAIL PROTECTED] wrote:
my @a is default(666);
print @a[2]; # prints 666
@a[4] = 1;
print @a[2]; # now prints undef :-(
[typo in third line corrected]
I don't understand your example. Can you explain it again, using words
of less than one
Nicholas Clark wrote:
I'm not sure. I think I like the idea of
@a[0] = undef;
being a blip, but
undef @a[0];
resetting the value to the default.
That thought crossed my mind as well before I got to your message ...
Conceptually perl5 already has a distinction between assigning
On Tue, Jan 28, 2003 at 04:07:17PM -0500, Aaron Sherman wrote:
I think this debate is easier if you think of defaults as overriding and
auto-vivification method on a container.
Hmm. I don't :-)
I think it is easier if you think of defaults as overriding undef.
On Tue, 2003-01-28 at 14:47,
On Tue, Jan 28, 2003 at 09:24:50AM -0800, Austin Hastings wrote:
--- Dan Sugalski [EMAIL PROTECTED] wrote:
At 8:47 AM + 1/28/03, Piers Cawley wrote:
$ref[$key]
an array or hash look-up???
Decided at runtime?
How? People use strings as array indices and ints/floats as
On Tue, Jan 28, 2003 at 03:06:19PM -0800, Damian Conway wrote:
Austin Hastings wrote:
--- Damian Conway [EMAIL PROTECTED] wrote:
my @a is default(666);
print @a[2];# prints 666
@a[4] = 1;
print @a[2];# now prints undef :-(
[typo in third line corrected]
Michael Lazzaro wrote:
The next (oft-asked) question is whether or not Cis computed denotes
read-only, or if you can store to an Cis computed array.
my @a is computed { $^index**2 };
@a[4] = 'something completely different';
I'd expect that Cis computed and Cis constant would be
Michael Lazzaro wrote:
2a) When a cell is explicitly re-undefined, does the default value take
effect?
my @a is Array( default = 'foo' ) = (1,2,3);
@a[1] = undef;
@a[1]; # undef, or 'foo'?
STRAWMAN ANSWER: 'foo'.
If Cundef is a valid value for a cell, then I should be
Aaron Sherman wrote:
auto-vivification will have to happen in some cases. e.g. if foo
requires a lvalue parameter. You can't know if an actual write will
happen, so you have to auto-vivify in order to pass a reference.
Or did I miss something there?
I think the idea is to use a special object
So ... with the discussion of what if i really wanted to put an undef in
there b/c it's not just that i haven't defined it but rather that it
really isn't defined. I KNOW it's not defined, and i'm now explicitly
saying it's undefined as opposed to before when i was implicitly
suggesting that i
attriel wrote:
So ... with the discussion of what if i really wanted to put an undef in
there b/c it's not just that i haven't defined it but rather that it
really isn't defined. I KNOW it's not defined, and i'm now explicitly
saying it's undefined as opposed to before when i was implicitly
52 matches
Mail list logo