Re: Slices

2005-03-24 Thread Larry Wall
On Tue, Mar 22, 2005 at 05:18:44PM +0100, Thomas Sandlaß wrote: : Rod Adams wrote: : multi sub postcircumflex::[ ](MyArray $obj : [EMAIL PROTECTED]) is rw {...} : : but I'll wait for S14 before speculating further. : : Will that ever be written? And if yes, will it be like S13 which : is

Re: Slices

2005-03-22 Thread Thomas Sandlaß
Rod Adams wrote: multi sub postcircumflex::[ ](MyArray $obj : [EMAIL PROTECTED]) is rw {...} but I'll wait for S14 before speculating further. Will that ever be written? And if yes, will it be like S13 which is basically saying that overloading is subsumed by A12/S12? I see the 'does' operator as

Re: Slices

2005-03-20 Thread Luke Palmer
Matt Diephouse writes: Is it possible to assign to an array slice? @array[0..4] = ( 0..4 ); # splice @array, 0, 5, 0..4 Of course. You could in Perl 5, right? If so (and I'm hoping it is), is there an equivalent of Ruby's `[]=` method? (Is there a way to define this behavior within my

Re: Slices

2005-03-20 Thread Rod Adams
Matt Diephouse wrote: Is it possible to assign to an array slice? @array[0..4] = ( 0..4 ); # splice @array, 0, 5, 0..4 If so (and I'm hoping it is), is there an equivalent of Ruby's `[]=` method? (Is there a way to define this behavior within my own array-like classes?) I assign to array and

Re: Slices

2005-03-20 Thread Brent 'Dax' Royal-Gordon
Luke Palmer [EMAIL PROTECTED] wrote: Can I use slice notation when dealing with strings? say $string[-1]; # say substr($string, -1); $string[0..2] = Hello; No. I'm pretty sure that's the Right Thing, too. First, the sixth element in a string depends on how you're defining

Re: Slices and iterators

2004-06-19 Thread Leopold Toetsch
Dan Sugalski [EMAIL PROTECTED] wrote: Px = Py[Pz] won't be, and we'll need to note whether Pz should be taken as an int, string, or PMC. (PMC for the fancier keying of hashes) ... A simple :i, :s, :p [...] suffix Do we really need that? The aggregate is responsible to do the right

Re: Slices and iterators

2004-06-16 Thread Leopold Toetsch
Dan Sugalski [EMAIL PROTECTED] wrote: *) We consider ways to make slices. I can see ops, or I can see basic functions. Either is fine, depends on how often the things are used. I'll start from the end of the proposal. What about just extending the keyed syntax: Px = Py[0] # key

Re: Slices and iterators

2004-06-16 Thread Dan Sugalski
At 11:25 AM +0200 6/16/04, Leopold Toetsch wrote: Dan Sugalski [EMAIL PROTECTED] wrote: *) We consider ways to make slices. I can see ops, or I can see basic functions. Either is fine, depends on how often the things are used. I'll start from the end of the proposal. What about just extending

Re: Slices and iterators

2004-06-16 Thread Brent 'Dax' Royal-Gordon
Dan Sugalski wrote: Which reminds me--we need to have a syntax to distinguish between key types. Perl already gives us two of the three: Px[Iy] Px{Sy} For the third, I suggest we extend the analogy: PxPz -- Brent Dax Royal-Gordon [EMAIL PROTECTED] Perl and Parrot hacker Oceania has

Re: Slices and iterators

2004-06-16 Thread Dan Sugalski
At 10:06 AM -0700 6/16/04, Brent 'Dax' Royal-Gordon wrote: Dan Sugalski wrote: Which reminds me--we need to have a syntax to distinguish between key types. Perl already gives us two of the three: Px[Iy] Px{Sy} For the third, I suggest we extend the analogy: PxPz Except it breaks really

Re: Slices and iterators

2004-06-16 Thread Dan Sugalski
At 7:48 PM +0200 6/16/04, Eirik Berg Hanssen wrote: Dan Sugalski [EMAIL PROTECTED] writes: At 10:06 AM -0700 6/16/04, Brent 'Dax' Royal-Gordon wrote: Dan Sugalski wrote: Which reminds me--we need to have a syntax to distinguish between key types. Perl already gives us two of the three:

Re: Slices and iterators

2004-06-16 Thread Eirik Berg Hanssen
Dan Sugalski [EMAIL PROTECTED] writes: At 10:06 AM -0700 6/16/04, Brent 'Dax' Royal-Gordon wrote: Dan Sugalski wrote: Which reminds me--we need to have a syntax to distinguish between key types. Perl already gives us two of the three: Px[Iy] Px{Sy} For the third, I suggest we extend

Re: Slices and iterators

2004-06-16 Thread Brent 'Dax' Royal-Gordon
Dan Sugalski wrote: Yeah, but given that this code will be generated by compilers 90+% of the time... the assembly generation and parsing of the assembly's easier with the postfix notation. My understanding is that compilers will generate an AST, not textual PIR. Thus, we are looking for a

Re: Slices and iterators

2004-06-14 Thread Luke Palmer
Dan Sugalski writes: The slice vtable entry should take as its parameter a slice pmc. This should be an array of typed from/to values, so we can do something like: @foo[0..2,4..8,12..]; with three entries in the slice array--one with a from/to of 0/2, one with 4/8, and one with

Re: Slices and iterators

2004-06-14 Thread Dan Sugalski
At 1:21 PM -0600 6/14/04, Luke Palmer wrote: Dan Sugalski writes: The slice vtable entry should take as its parameter a slice pmc. This should be an array of typed from/to values, so we can do something like: @foo[0..2,4..8,12..]; with three entries in the slice array--one with a from/to

Re: Slices and iterators

2004-06-14 Thread Luke Palmer
Dan Sugalski writes: At 1:21 PM -0600 6/14/04, Luke Palmer wrote: Dan Sugalski writes: The slice vtable entry should take as its parameter a slice pmc. This should be an array of typed from/to values, so we can do something like: @foo[0..2,4..8,12..]; with three entries in the

Re: slices

2001-05-25 Thread Bart Lateur
On Thu, 24 May 2001 22:19:12 -0400, James Mastros wrote: But what about: @foo[(1,2,3)]? Are those parens a list-maker, or are they a scalar expression using the comma operator. Both. But in this case, I'd say: it depends on the context the slice is called in. @bar = @foo[(1,2,3)];

Re: slices

2001-05-25 Thread Uri Guttman
BL == Bart Lateur [EMAIL PROTECTED] writes: BL @bar = @foo[(1,2,3)]; BL is the same as BL @bar = (@foo[1], @foo[2], @foo[3]); BL or: just an ordinary slice. OTOH, BL $bar = @foo[(1, 2, 3)]; BL is the same as BL $bar = (@foo[1], @foo[2], @foo[3]); the real problem

RE: slices

2001-05-25 Thread David Whipp
Uri Guttman wrote: so we have to get some way to denote a list of indices as a slice and also support some range operation as a possible component of that list with the knowledge that the range arguments are also indices and not just integers. i don't have any syntax ideas for this at the

Re: slices

2001-05-24 Thread Raul Miller
First off, sorry about the noise -- I expect that Larry will have this mostly worked out already. [And, when I re-read Apocalypse 2, I saw that I had almost literally stolen some of his sentences. *blush*] On Thu, May 24, 2001 at 10:19:12PM -0400, James Mastros wrote: But what about: