Re: Perl defined Object, Array, Hash classes

2005-06-13 Thread Larry Wall
You shouldn't be able to reopen/clobber an existing class/module unless you specify class Object is augmented {...} class Object is replaced {...} or some such (the trait names are still negotiable). In general, private classes should start with "my" or "our", though I don't know if Pugs

Perl defined Object, Array, Hash classes

2005-06-13 Thread Eric
Hey, Found out this morning that wizard.p6 suddenly stopped wondering and I was stumped as to why. The autrijus came along and pointed out that i was defineing an Object class of my own. This was obliterating the built in class causing all other classes to fail to work at all. It would seem fro

RE: Array/Hash Slices, multidimensional

2004-04-16 Thread Abhijit A. Mahabal
On Fri, 16 Apr 2004, Aaron Sherman wrote: > > > @matrix... = <<1 0 0 1>>; > > In the case of: > > @matrix = <<1 2 3 4 5>>; > > You need only add the type: > > int @matrix = <<1 2 3 4 5>>; > There is no string phase, or at least should never be. > The compiler can > pre-compute the

RE: Array/Hash Slices, multidimensional

2004-04-16 Thread Aaron Sherman
On Thu, 2004-04-15 at 18:23, Austin Hastings wrote: > > @matrix... = <<1 0 0 1>>; > Keep in mind that you're using a quoting operator. For numbers, you can just > use (0, 1, 2, 3) > and probably be better understood. (The <> approach will > work, but it will take all the numbers through a str

Re: Array/Hash Slices, multidimensional

2004-04-15 Thread Luke Palmer
Austin Hastings writes: > > > > -Original Message- > > From: Abhijit A. Mahabal [mailto:[EMAIL PROTECTED] > > Sent: Thursday, 15 April, 2004 05:13 PM > > To: [EMAIL PROTECTED] > > Subject: Array/Hash Slices, multidimensional > > > > >

RE: Array/Hash Slices, multidimensional

2004-04-15 Thread Austin Hastings
> -Original Message- > From: Abhijit A. Mahabal [mailto:[EMAIL PROTECTED] > Sent: Thursday, 15 April, 2004 05:13 PM > To: [EMAIL PROTECTED] > Subject: Array/Hash Slices, multidimensional > > > As the hash syntax is being worked out, I thought it'd be a good t

Array/Hash Slices, multidimensional

2004-04-15 Thread Abhijit A. Mahabal
As the hash syntax is being worked out, I thought it'd be a good time to ask if the following will be supported in some form: If I have some structure like %foo{"monday"}, %foo{"tuesday"} etc, I can set their values enmass using: %foo<> = <>; What if I had %foo{"monday"}{"food_ex

Re: @array = %hash

2002-09-08 Thread Me
> [run time control of assignment behavior when array contains pairs] How much have I misunderstood things from a mechanisms available point of view (as against a practical / nice way to do things) when I suggest something along the lines of: my sub op:= (*@list : %adverbs) { ...

Re: @array = %hash

2002-09-03 Thread Dan Sugalski
At 8:48 AM -0600 9/3/02, Luke Palmer wrote: > > Hmm... I think I'd rather see >> >>my $foo is Bag = @array.as('Bag'); >> >> The idea being that one could treat hashes and arrays as syntactic >> vitamins meaning 'Dictionary' (to use the Smalltalk term) and >> 'OrderedCollection', but all Co

Re: @array = %hash

2002-09-03 Thread Luke Palmer
> Hmm... I think I'd rather see > > my $foo is Bag = @array.as('Bag'); > > The idea being that one could treat hashes and arrays as syntactic > vitamins meaning 'Dictionary' (to use the Smalltalk term) and > 'OrderedCollection', but all Collections would implement an C > method allowing conve

Re: @array = %hash

2002-09-03 Thread Piers Cawley
Damian Conway <[EMAIL PROTECTED]> writes: > Uri Guttman wrote: > >> but what simon was saying (and i agree) is the the pair IS a single >> item. it becomes the key and its value is 'scalars'. > > No. If it's a PAIR, then its key is the key and its value is the value. > > >> hashes can now take ob

Re: @array = %hash

2002-09-03 Thread Piers Cawley
David Whipp <[EMAIL PROTECTED]> writes: > Piers Cawley wrote: >> Maybe we should just say 'sod it' and implement the entire Smalltalk >> Collection hierarchy and have done with it? Sets, bags, hashes >> (dictionaries for the Smalltalker), whatever, all have their uses... > > I'm not sure if you w

Re: @array = %hash

2002-09-02 Thread Piers Cawley
Uri Guttman <[EMAIL PROTECTED]> writes: >> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes: > > SC> [EMAIL PROTECTED] (Damian Conway) writes: > >> > hashes can now take objects as keys and won't just stringify them. > >> > >> Correct. But I believe that's only if the hash has a prope

Re: @array = %hash

2002-09-02 Thread Damian Conway
Uri Guttman wrote: > but what about mixing pairs and scalars which was the core of this > thread? Then you get whatever behaviour you defined the hash to give. > by default it seems assigning such a list to a hash would use > the pairs as 2 elements It's not the right way to think about wha

Re: @array = %hash

2002-09-02 Thread Uri Guttman
> "DC" == Damian Conway <[EMAIL PROTECTED]> writes: DC> Uri Guttman wrote: >> so what that attribute does is force the hash to keep all pairs as >> single objects. but what about run time control of it? sometimes you >> might want a list of pairs to be handled like pairs and other tim

Re: @array = %hash

2002-09-02 Thread Damian Conway
Uri Guttman wrote: > so what that attribute does is force the hash to keep all pairs as > single objects. but what about run time control of it? sometimes you > might want a list of pairs to be handled like pairs and other times you > want pairs to be scalars in a hash assignment. is there any wa

Re: @array = %hash

2002-09-01 Thread Uri Guttman
> "SC" == Simon Cozens <[EMAIL PROTECTED]> writes: SC> [EMAIL PROTECTED] (Damian Conway) writes: >> > hashes can now take objects as keys and won't just stringify them. >> >> Correct. But I believe that's only if the hash has a property that marks >> its keys as being objects, not

Re: @array = %hash

2002-09-01 Thread Simon Cozens
[EMAIL PROTECTED] (Damian Conway) writes: > > hashes can now take objects as keys and won't just stringify them. > > Correct. But I believe that's only if the hash has a property that marks > its keys as being objects, not strings: > > my %hash is keyed(REF); > > And, even if that's the d

Re: @array = %hash

2002-09-01 Thread Damian Conway
Uri Guttman wrote: > but what simon was saying (and i agree) is the the pair IS a single > item. it becomes the key and its value is 'scalars'. No. If it's a PAIR, then its key is the key and its value is the value. > hashes can now take objects as keys and won't just stringify them. Correct.

Re: @array = %hash

2002-08-31 Thread Uri Guttman
> "KF" == Ken Fox <[EMAIL PROTECTED]> writes: KF> Simon Cozens wrote: >> [EMAIL PROTECTED] (Damian Conway) writes: >> %hash4 = ("Something", "mixing", pairs => and, "scalars"); >>> >>> That's perfectly okay (except you forgot the quotes around the >>> and you have an odd

Re: @array = %hash

2002-08-31 Thread Ken Fox
Simon Cozens wrote: > [EMAIL PROTECTED] (Damian Conway) writes: > >>> %hash4 = ("Something", "mixing", pairs => and, "scalars"); >> >>That's perfectly okay (except you forgot the quotes around the >>and you have an odd number of elements initializing the hash). > > Urgh, no. Either a pair is a

Re: @array = %hash

2002-08-31 Thread Simon Cozens
[EMAIL PROTECTED] (Damian Conway) writes: > > %hash4 = ("Something", "mixing", pairs => and, "scalars"); > > That's perfectly okay (except you forgot the quotes around the > and you have an odd number of elements initializing the hash). Urgh, no. Either a pair is an atomic entity or it isn't.

Re: @array = %hash

2002-08-31 Thread Damian Conway
Nicholas Clark asked: >%hash3 = @kv_array > > Is perl6 going to spot that @kv_array has an even number of entries, all > are scalars (no pairs), and so do this > >for @kv_array -> key, value { >%hash3{$key} = $value; >} Yes. Just like in Perl 5. > Or is it going to treat

Re: @array = %hash

2002-08-31 Thread Miko O'Sullivan
From: "Nicholas Clark" <[EMAIL PROTECTED]> > In Damian's excellent perl6 talk, I think he said that by default a hash > in list context will return a list of pairs. Hence this > >@array = %hash > > for %hash with n keys would give an array of n element

RE: @array = %hash

2002-08-30 Thread David Whipp
Piers Cawley wrote: > Maybe we should just say 'sod it' and implement the entire Smalltalk > Collection hierarchy and have done with it? Sets, bags, hashes > (dictionaries for the Smalltalker), whatever, all have their uses... I'm not sure if you were being facetious, but I do think all the funct

RE: @array = %hash

2002-08-30 Thread David Whipp
Steffen Mueller > > %hash4 = ("Something", "mixing", pairs => and, "scalars"); >1 23 4 5 > Perl5 says "Odd number of elements in hash assignment at -e line 1." > And Perl6 should, too. Hmm, I rather like the idea of thinking of a %foo variable as

Re: @array = %hash

2002-08-30 Thread Simon Cozens
[EMAIL PROTECTED] (Steffen Mueller) writes: > > %hash4 = ("Something", "mixing", pairs => and, "scalars"); >1 23 4 5 > Perl5 says "Odd number of elements in hash assignment at -e line 1." > And Perl6 should, too. Except that a pair is a single th

Re: @array = %hash

2002-08-30 Thread Steffen Mueller
Nicholas Clark wrote: [...] > And what happens if I write > > %hash4 = ("Something", "mixing", pairs => and, "scalars"); 1 23 4 5 Perl5 says "Odd number of elements in hash assignment at -e line 1." And Perl6 should, too. IMHO, your example isn't

@array = %hash

2002-08-30 Thread Nicholas Clark
In Damian's excellent perl6 talk, I think he said that by default a hash in list context will return a list of pairs. Hence this @array = %hash for %hash with n keys would give an array of n elements, all pairs. If you want the perl5 tradition of a list alternating key,value,key,

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-25 Thread Sterin, Ilya
t: 07/24/2001 6:03 PM Subject: Re: array/hash manipulation [was :what's with 'with'?] "Sterin, Ilya" wrote: > But now I am trying to figure out, if you are not comparing elements of the > array and for example if you need to loop through 3 arrays at the same time,

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-21 Thread Sterin, Ilya
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Saturday, July 21, 2001 5:50 AM > To: Sterin, Ilya; 'raptor '; Perl 6 Language > Subject: RE: array/hash manipulation [was :what's with 'with'?] > > > "

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-21 Thread Sterin, Ilya
> -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Saturday, July 21, 2001 5:50 AM > To: Sterin, Ilya; 'raptor '; Perl 6 Language > Subject: RE: array/hash manipulation [was :what's with 'with'?] > > > "

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-21 Thread jh_lists
"Sterin, Ilya" <[EMAIL PROTECTED]> wrote: > Just one question, how > would merge behave on two different sized arrays. > > @a = (1..5); > @b = (1..10); > merge(@a, @b); > > ##Would return (1,1,2,2,3,3,4,4,5,5,?? > > Would it stop on the shortest array. Couldn't quite find such explanat

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
> -Original Message- > From: Jeremy Howard [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 20, 2001 8:40 PM > To: Sterin, Ilya; 'raptor '; [EMAIL PROTECTED] > Subject: Re: array/hash manipulation [was :what's with 'with'?] > > > "Ste

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Jeremy Howard
"Sterin, Ilya" <[EMAIL PROTECTED]> wrote: > Hmmm. Didn't think about that. That would be a nice way, that way you can > manipulate it's behaviour depending with how many aliases you provide. > > for my $el1, $el2 ( (@foo, @bar) ) { > print "$el\n" > } > > $el1 and $el2 would of course be ali

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Jeremy Howard
"John Porter" wrote: > Sterin, Ilya wrote: > > Don't really know which would be more helpful, since I first need to find a > > scenerio where I would use this facility, then what result would I expect > > once the shortest list runs out. > > Let us ask the PDL folks. > > In fact, I'm quite sure th

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread John Porter
Sterin, Ilya wrote: > Don't really know which would be more helpful, since I first need to find a > scenerio where I would use this facility, then what result would I expect > once the shortest list runs out. Let us ask the PDL folks. In fact, I'm quite sure this has been done already. -- Jo

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
s out. Do I still need the values of the longer list, for one reason or another, or do I want the loop aborted? Ilya -Original Message- From: David L. Nicol To: Sterin, Ilya Cc: 'raptor '; '[EMAIL PROTECTED] ' Sent: 07/20/2001 1:44 PM Subject: Re: array/hash manipulatio

RE: array/hash manipulation

2001-07-20 Thread Eric Roode
On Friday, July 20, Ilya Sterin wrote: >No, I don't think you are understanding it correctly. It's not about >looping sequentially, but rather simultaneouly, for comparison purposes. > >@foo = (1,2,3); >@bar = (1,2,3); >for my ($foo, $bar) (@foo, @bar) #As the index for @foo increases, so >

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
#does @bar index { print "OK\n" if $foo == $bar; } Will print... OK OK OK Ilya -Original Message- From: Eric Roode To: [EMAIL PROTECTED] Sent: 07/20/2001 11:30 AM Subject: Re: array/hash manipulation [was :what's with 'with'?] on Fri Jul 20, Mark REED wrote: >I&#x

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
ed To: '[EMAIL PROTECTED] ' Sent: 07/20/2001 11:21 AM Subject: Re: array/hash manipulation [was :what's with 'with'?] On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote: > But this will be flattened, so I would think > > for my($key, $val)(%my_hash) >

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Eric Roode
on Fri Jul 20, Mark REED wrote: >I'm sorry, but I fail to see how this is a big improvement over the >current version: > >while (my ($key, $val) = each %my_hash) >{ ... } And a workalike to while ( ($a,$b,$c) = (@a, @b, @c) ) or for my ($el1, $el2) (@foo, @bar) is very e

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Mark J. Reed
Well, other than the fact that the while(each) doesn't do aliasing. Since that would be the whole point, ignore that last message. On Fri, Jul 20, 2001 at 01:21:57PM -0400, Mark J. Reed wrote: > On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote: > > But this will be flattened, so I wo

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread raptor
ooops I forgot if the vars in for are aliesed then it will be ok for using it like 'with' : for my $el ( $Request->{Param} ) { print $el{qsParam1} print $el{qsParam2} } but then what will be $_ ... alias OR copy !?! :") I mean mostly backward compatibility... One other way is 'local' to

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Mark J. Reed
On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote: > But this will be flattened, so I would think > > for my($key, $val)(%my_hash) > { ... } > > Would be a great convenience. $key and $val being aliased accordingly. I'm sorry, but I fail to see how this is a big improvement over the

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
But this will be flattened, so I would think for my($key, $val)(%my_hash) { ... } Would be a great convenience. $key and $val being aliased accordingly. Ilya -Original Message- From: raptor To: Sterin, Ilya; [EMAIL PROTECTED] Sent: 07/20/2001 9:10 AM Subject: Re: array/hash manipul

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread raptor
> Hmmm. Didn't think about that. That would be a nice way, that way you can > manipulate it's behaviour depending with how many aliases you provide. > > for my $el1, $el2 ( (@foo, @bar) ) { > print "$el\n" > } > > $el1 and $el2 would of course be aliases, right? ]- yes ALIASING will be bett

RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya
a -Original Message- From: raptor To: [EMAIL PROTECTED] Sent: 07/20/2001 3:37 AM Subject: Re: array/hash manipulation [was :what's with 'with'?] > So my initial code (which I modified a little...) > > for ( @foo, @bar ) { > print "$_[0] : $_[1]\n";

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Jeremy Howard
hould be done via these proposed functions. > > PS. I was thinking of that before, what if we have something let's call it > 'transform' for transformation of any structure to other structure.. but as > i thought it should combine in some way the features of > switc

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread John Porter
raptor wrote: > > for my $el1, $el2 ( @foo, @bar ) { Hopefully you mean for my $el1, my $el2 ( @foo, @bar ) { or maybe for [ my $el1, my $el2 ] ( @foo, @bar ) { And yes, it's an old idea. > PS. I was thinking of that before, what if we have something let's call it > 'transform' for

Re: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread raptor
l.org/rfc/148.pod so may be what must be the order of passing the arguments and other stuff should be done via these proposed functions. PS. I was thinking of that before, what if we have something let's call it 'transform' for transformation of any structure to other structure.. but a