Re: Extending classes in a lexical scope?

2009-01-14 Thread Ovid
- Original Message > As far as I know, "Perl6Array" should _not_ be showing up in > Perl 6's namespace, and if it is doing so, that's a reportable > bug. I was just being sloppy. I was using that in PIR, not Rakudo, and I mistyped the type -- er, I wrote the wrong class name in writin

Re: Extending classes in a lexical scope?

2009-01-13 Thread Patrick R. Michaud
On Mon, Jan 12, 2009 at 02:02:38PM -0800, Larry Wall wrote: > > As for Perl6Array, that's a rakudo type, not a Perl 6 type, so I > can't speak for it. I'd just as soon that the name not show up in > Perl 6's namespace, if I had my druthers. As far as I know, "Perl6Array" should _not_ be showing

Re: Extending classes in a lexical scope?

2009-01-12 Thread Larry Wall
On Mon, Jan 12, 2009 at 04:38:07PM -0800, Jon Lang wrote: : No, you don't understand me. The Foo/Bar example I was giving was : independent of your example. Rephrasing in your terms, consider the : possibility of a class that's derived from Array, for whatever reason; : call it "Ring". Now you d

Re: Extending classes in a lexical scope?

2009-01-12 Thread Jon Lang
Ovid wrote: > - Original Message > >> From: Jon Lang > >> > Actually, I'd prefer to go much further than this: >> > >> > use Core 'MyCore'; >> > >> > And have that override core classes lexically. >> > >> > That solves the "but I want it MY way" issue that many Perl and Ruby >> programme

Re: Extending classes in a lexical scope?

2009-01-12 Thread Larry Wall
On Mon, Jan 12, 2009 at 02:43:37PM -0800, Ovid wrote: : Actually, I'd prefer to go much further than this: : : use Core 'MyCore'; : : And have that override core classes lexically. We're already speccing a way to substitute a different prelude from the command line, in order to desugar -n and

Re: Extending classes in a lexical scope?

2009-01-12 Thread Ovid
- Original Message > From: Jon Lang > > Actually, I'd prefer to go much further than this: > > > > use Core 'MyCore'; > > > > And have that override core classes lexically. > > > > That solves the "but I want it MY way" issue that many Perl and Ruby > programmers have, but they don't

Re: Extending classes in a lexical scope?

2009-01-12 Thread Jon Lang
Ovid wrote: > Actually, I'd prefer to go much further than this: > > use Core 'MyCore'; > > And have that override core classes lexically. > > That solves the "but I want it MY way" issue that many Perl and Ruby > programmers have, but they don't shoot anyone else in the foot. Since 'use' import

Re: Extending classes in a lexical scope?

2009-01-12 Thread Ovid
- Original Message > From: Moritz Lenz > > That is the preferred way to avoid action-at-a-distance in P6. > > so if I do that, will a 'my @a' use that new Array class? > > Actually I'd prefer it if there were some kind of mechanism to set a > default implementation type, so that I cou

Re: Extending classes in a lexical scope?

2009-01-12 Thread Moritz Lenz
Larry Wall wrote: > : however, I believe > : that it _is_ possible to derive a new class whose "name" differs from > : an existing class only in terms of version information, such that it > : is substituted for the original class within the lexical scope where > : it was defined, barring explicit i

Re: Extending classes in a lexical scope?

2009-01-12 Thread Larry Wall
On Mon, Jan 12, 2009 at 03:38:04AM -0800, Jon Lang wrote: : Ovid wrote: : > Is it possible to modify the core Perl6Array class like that (without extra keywords)? If so, is it possible for each programmer to make such a change so that it's lexically scoped? : : AFAIK, it is not possible to modi

Re: Extending classes in a lexical scope?

2009-01-12 Thread Jon Lang
Ovid wrote: > Is it possible to modify the core Perl6Array class like that (without extra > keywords)? If so, is it possible for each programmer to make such a change > so that it's lexically scoped? AFAIK, it is not possible to modify a core class; however, I believe that it _is_ possible to d

Extending classes in a lexical scope?

2009-01-12 Thread Ovid
Let's say two people want to add a 'shuffle' method to all arrays. Alice wants to have it look like this: method shuffle (*...@array is rw) { @array .= pick(*); } Bob wants it to look like this: method shuffle (*...@array is rw) { @array = @array[0 .. @array/2] Z @arr...@array