Re: Array Questions

2003-01-17 Thread Damian Conway
Piers Cawley observed: BTW, C is just sick! (i.e. I'll *definitely* be using it ;-) Surely anyone who does C<< my Array @foo >>, or C<< my Scalar $foo >> will be using it, albeit indirectly. Of course, but without the brain-twisting effect of the repeated classname. ;-) Damian

Re: Array Questions

2003-01-17 Thread Damian Conway
Jonathan Scott Duff wrote: > will this: my $a $b; be illegal? I certainly hope so! Damian

Re: Array Questions

2003-01-17 Thread Damian Conway
Michael Lazzaro wrote: Great -- then I have only one more question, I think. In the words of a certain cartoon character, what's *this* button do? my $b is $a; Syntax error, I'd expect. Though the desired effect could probably be achieved with the C meta-property: my $b is prop($a); D

Re: Array Questions

2003-01-15 Thread Simon Cozens
[EMAIL PROTECTED] (Michael Lazzaro) writes: > Great -- then I have only one more question, I think. In the words of > a certain cartoon character, what's *this* button do? > >my $b is $a; I think at this stage it's probably worth reminding everyone that not every string of characters *needs*

Re: Array Questions

2003-01-14 Thread Dan Sugalski
At 9:23 AM -0800 1/14/03, Michael Lazzaro wrote: On Tuesday, January 14, 2003, at 02:24 AM, Piers Cawley wrote: Michael Lazzaro <[EMAIL PROTECTED]> writes: Great -- then I have only one more question, I think. In the words of a certain cartoon character, what's *this* button do? my $b is $

Re: Array Questions

2003-01-14 Thread Michael Lazzaro
On Tuesday, January 14, 2003, at 02:24 AM, Piers Cawley wrote: Michael Lazzaro <[EMAIL PROTECTED]> writes: Great -- then I have only one more question, I think. In the words of a certain cartoon character, what's *this* button do? my $b is $a; Compile time error. 'is' is a compile time pr

Re: Array Questions

2003-01-14 Thread Piers Cawley
Damian Conway <[EMAIL PROTECTED]> writes: > Michael Lazzaro wrote: >> Which, in turn, implies that the lines: >>my Foo $a; # (1) >>my $a is Foo; # (2) >>my Foo $a is Foo; # (3) >> are all subtly different. (2) and (3) (auto)instantiate a Foo, but >> (1) does not. > > Corr

Re: Array Questions

2003-01-14 Thread Piers Cawley
Michael Lazzaro <[EMAIL PROTECTED]> writes: > On Thursday, January 9, 2003, at 03:24 AM, Damian Conway wrote: >> Michael Lazzaro asked: >>>class FileBasedHash is Hash { ...stuff... }; >>>my %data is FileBasedHash('/tmp/foo.txt'); >> Yes. > >>>my $path = '/tmp/foo.txt'; >>>my %data

Re: Array Questions

2003-01-12 Thread Michael Lazzaro
Luke Palmer wrote: > I would imagine that would only work if $a was known at compile time: I think we could do it at runtime too. You could conceivably use runtime resolution to, for example, choose from between several different caching behaviors to be passed to a complex routine: sub get_c

Re: Array Questions

2003-01-10 Thread Luke Palmer
> From: Thom Boyer <[EMAIL PROTECTED]> > Date: Fri, 10 Jan 2003 13:57:26 -0700 > > From: Michael Lazzaro [mailto:[EMAIL PROTECTED]] > > But I don't know if these two > > lines would really have the same result, ... > > > > $a = MyScalar; > > $a = 'MyScalar'; > > Hrmm. Didn't Larry decr

RE: Array Questions

2003-01-10 Thread Thom Boyer
From: Michael Lazzaro [mailto:[EMAIL PROTECTED]] > But I don't know if these two > lines would really have the same result, ... > > $a = MyScalar; > $a = 'MyScalar'; Hrmm. Didn't Larry decree that there are no bare words, but that a class name will evaluate to the string representing th

Re: Array Questions

2003-01-10 Thread Jonathan Scott Duff
On Fri, Jan 10, 2003 at 10:28:49AM -0800, Michael Lazzaro wrote: > Great -- then I have only one more question, I think. In the words of > a certain cartoon character, what's *this* button do? > >my $b is $a; And no matter what that button does, will this: my $a $b; be illegal? -

Re: Array Questions

2003-01-10 Thread Michael Lazzaro
On Thursday, January 9, 2003, at 03:24 AM, Damian Conway wrote: Michael Lazzaro asked: class FileBasedHash is Hash { ...stuff... }; my %data is FileBasedHash('/tmp/foo.txt'); Yes. my $path = '/tmp/foo.txt'; my %data is FileBasedHash($path); Indeed Great -- then I have only one

Re: Array Questions

2003-01-09 Thread Damian Conway
Michael Lazzaro asked: OK, next question. Is _THIS_ possible? class FileBasedHash is Hash { ...stuff... }; my %data is FileBasedHash('/tmp/foo.txt'); Yes. Though we would need a syntax for specifying that string parameter for the generic C class. And, of course, a mechanism for constru

Re: Array Questions

2003-01-08 Thread Michael Lazzaro
On Wednesday, January 8, 2003, at 10:39 AM, Chris Dutton wrote: I would ask, if it's possible to inherit from Array or Hash, is it possible to inherit from one which has a constrained storage type? my WeirdHash is int Hash { ... } Yes, I think that was tentatively confirmed a while back. But

Re: Array Questions

2003-01-08 Thread Chris Dutton
On Wednesday, January 8, 2003, at 01:32 PM, Michael Lazzaro wrote: On Wednesday, January 8, 2003, at 02:13 AM, Damian Conway wrote: Michael Lazzaro wrote: The remaining big question, then, is whether you can truly subclass Array to achieve C-like behavior: class MyArray is Array { ... };

Re: Array Questions

2003-01-08 Thread Michael Lazzaro
On Wednesday, January 8, 2003, at 02:13 AM, Damian Conway wrote: Michael Lazzaro wrote: The remaining big question, then, is whether you can truly subclass Array to achieve C-like behavior: class MyArray is Array { ... }; my @a is MyArray; Oh yes, I would certainly expect that this has t

Re: Array Questions

2003-01-08 Thread Michael Lazzaro
On Wednesday, January 8, 2003, at 02:17 AM, Damian Conway wrote: Jonathan Scott Duff wrote: On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote: > Which, in turn, implies that the lines: my Foo $a; # (1) my $a is Foo; # (2) my Foo $a is Foo; # (3) are all

Re: Array Questions

2003-01-08 Thread Luke Palmer
> From: Deborah Ariel Pickett <[EMAIL PROTECTED]> > Date: Wed, 8 Jan 2003 09:42:18 +1100 (EST) > > [...] But everybody has to learn Perl once. I agree with you entirely :) Luke

Re: Array Questions

2003-01-08 Thread Damian Conway
Jonathan Scott Duff wrote: On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote: > Which, in turn, implies that the lines: my Foo $a; # (1) my $a is Foo; # (2) my Foo $a is Foo; # (3) are all subtly different. (2) and (3) (auto)instantiate a Foo, but (1) doe

Re: Array Questions

2003-01-08 Thread Damian Conway
Michael Lazzaro wrote: my int @a; my @a returns int; my @a is Array of int; my @a is Array returns int; my int @a is Array; Those lines are all absolutely synonymous, and all declare an array of integers, right? Right. (This week, at least ;-) Likewise, Arrays have methods

Re: Array Questions

2003-01-07 Thread Austin Hastings
--- Austin Hastings <[EMAIL PROTECTED]> wrote: > > --- Deborah Ariel Pickett <[EMAIL PROTECTED]> wrote: > > > Seriously, if they're smart enough to run a text editor, I think > > it's > > > safe to say that they can handle the conceptual difference > between > > the > > > "length" (mins:secs) of

Re: Array Questions

2003-01-07 Thread Austin Hastings
--- Deborah Ariel Pickett <[EMAIL PROTECTED]> wrote: > > Seriously, if they're smart enough to run a text editor, I think > it's > > safe to say that they can handle the conceptual difference between > the > > "length" (mins:secs) of a video, and the "length" (feet:inches) of > the > > mag-tape th

Re: Array Questions

2003-01-07 Thread Deborah Ariel Pickett
> > Perhaps .size for number-of-elements and .length for length-of-string > > would work? > > This would just cause them to Think About Things A Different But > Equally Wrong Way: as assembly language objects whose SIZE in bytes is > the determining component of their existence. > I am happy to

Re: Array Questions

2003-01-07 Thread Austin Hastings
--- Deborah Ariel Pickett <[EMAIL PROTECTED]> wrote: > Getting off topic here (a bit), but I think it's a Mistake to have > .length mean different things on an array ["Number of elements"] and > a (string) scalar ["number of characters"]. > While there will never be any confusion on the part o

Re: Array Questions

2003-01-07 Thread Piers Cawley
"Mark J. Reed" <[EMAIL PROTECTED]> writes: > On 2003-01-07 at 11:31:13, Mr. Nobody wrote: >> .length is unneeded, since an array gives its length in numeric context, so >> you can just say +@a. > Unneeded, but harmless. > >> grep shouldn't be an array method either, it should be >> like the perl5

Re: Array Questions

2003-01-07 Thread Michael Lazzaro
On Tuesday, January 7, 2003, at 02:05 PM, Deborah Ariel Pickett wrote: On 2003-01-07 at 11:31:13, Mr. Nobody wrote: .length is unneeded, since an array gives its length in numeric context, so you can just say +@a. Unneeded, but harmless. Getting off topic here (a bit), but I think it's a Mi

Re: Array Questions

2003-01-07 Thread Deborah Ariel Pickett
> On 2003-01-07 at 11:31:13, Mr. Nobody wrote: > > .length is unneeded, since an array gives its length in numeric context, so > > you can just say +@a. > Unneeded, but harmless. Getting off topic here (a bit), but I think it's a Mistake to have .length mean different things on an array ["Number

Re: Array Questions

2003-01-07 Thread Michael Lazzaro
On Tuesday, January 7, 2003, at 11:26 AM, Jonathan Scott Duff wrote: On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote: Let's operate from the assumption -- or somebody please CORRECT ME IF I'M WRONG -- that the following syntax is valid: my int @a;# 1

Re: Array Questions

2003-01-07 Thread Mark J. Reed
On 2003-01-07 at 11:31:13, Mr. Nobody wrote: > .length is unneeded, since an array gives its length in numeric context, so > you can just say +@a. Unneeded, but harmless. > grep shouldn't be an array method either, it should be > like the perl5 grep, as it is often used on lists, "grep /foo/, key

Re: Array Questions

2003-01-07 Thread Mr. Nobody
--- Michael Lazzaro <[EMAIL PROTECTED]> wrote: > Arrays have methods: > > my int @a = (1..100); > print @a.length; # prints "100" > my @b = @a.grep { $_ > 50 }; # gets 51..100 .length is unneeded, since an array gives its length in numeric context, so you can just say

Re: Array Questions

2003-01-07 Thread Jonathan Scott Duff
On Tue, Jan 07, 2003 at 10:04:09AM -0800, Michael Lazzaro wrote: > I think this may be another case of "it depends on what the word > 'object' means", e.g. we're talking past each other. I hope. > > Let's operate from the assumption -- or somebody please CORRECT ME IF > I'M WRONG -- that the fo