Re: Aliasing methods in CPAN roles

2009-10-20 Thread Raphael Descamps
Am Montag, den 19.10.2009, 16:43 -0700 schrieb Jon Lang: > Raphael Descamps wrote: > > I personally don't understand why we don't have a exclude and alias > > operator in Perl 6 but I have not read all the synopses and don't have > > an overview. > > I don't think that it's explicitly spelled out

Re: Aliasing methods in CPAN roles

2009-10-19 Thread Jon Lang
Raphael Descamps wrote: > In the original traits paper the aliasing is not "deep": to respect the > flattening property, the semantic of the role must not change, so > aliasing a recursive method will call the original method. It's a known > theoretical weakness of the traits paper and "freezing ro

Re: Aliasing methods in CPAN roles

2009-10-19 Thread Jon Lang
Raphael Descamps wrote: > I personally don't understand why we don't have a exclude and alias > operator in Perl 6 but I have not read all the synopses and don't have > an overview. I don't think that it's explicitly spelled out anywhere; but the reason is fairly straightforward: exclude and alias

Re: Aliasing methods in CPAN roles

2009-10-19 Thread David Green
On 2009-Oct-18, at 3:44 pm, Jon Lang wrote: David Green wrote: I would expect that role Logging { method log(Numeric $x:) {...} } means the invocant is really of type Numeric & Logging, without Logging having to do Numeric. On the other hand, I can see that strictly that might not make se

Re: Aliasing methods in CPAN roles

2009-10-19 Thread Raphael Descamps
Am Freitag, den 16.10.2009, 10:54 +0400 schrieb Richard Hainsworth: > Arising out of "Freezing Roles" is a related question. > > Suppose I download a module from CPAN with a role I want to use, but it > introduces a method that I want that is in conflict with an existing > method (say one taken

Re: Aliasing methods in CPAN roles

2009-10-18 Thread Jon Lang
David Green wrote: > Jon Lang wrote: >> >> This implies that both Logging and Math do Numeric, since the invocant >> ought to be of a type that the class does. > > I would expect that >    role Logging { method log(Numeric $x:) {...} } > means the invocant is really of type Numeric & Logging, witho

Re: Aliasing methods in CPAN roles

2009-10-18 Thread David Green
On 2009-Oct-17, at 1:55 am, Jon Lang wrote: This implies that both Logging and Math do Numeric, since the invocant ought to be of a type that the class does. I would expect that role Logging { method log(Numeric $x:) {...} } means the invocant is really of type Numeric & Logging, without

Re: Aliasing methods in CPAN roles

2009-10-17 Thread Jon Lang
David Green wrote: > Aha, so the bark:(Dog:) syntax identifies the method by its signature as > well, thus distinguishing it from the .bark:(Tree:) method.  This works fine > when the sigs can distinguish the invocants, which is very common.  However, > I could have ambiguous methods even including

Re: Aliasing methods in CPAN roles

2009-10-16 Thread David Green
On 2009-Oct-16, at 12:54 am, Richard Hainsworth wrote: Is there syntactic sugar for aliasing the conflicting method? Eg. something like does XML :db-write; There needs to be something more than sugar: making a new class or role with different methods will break substitutability. However, w

Re: Aliasing swapped values

2005-04-10 Thread Juerd
Ovid skribis 2005-04-10 10:47 (-0700): > Apologies if this has been covered. What should this do? > ($x,$y) := ($y,$x); It would let $x be a second name for the variable that is also called $y, and $y for $x. The old names $x and $y are overwritten, so essentially the names for the two variable

Re: Aliasing an array slice

2003-07-20 Thread David Storrs
On Fri, Jul 18, 2003 at 06:05:52PM -0400, Benjamin Goldberg wrote: > What would happen if I used 1,2,3 instead of 1..3? Would it do the same > thing? I would think so. > I wanna know what happens if I do: > >@a[0,2,4] = qw/ a b c d e /; Yup, you're right, I didn't consider non-cont

Re: Aliasing an array slice

2003-07-18 Thread Luke Palmer
Benjamin Golberg writes: > Luke Palmer wrote: > > > > > David Storrs wrote: > > > > > > > > Thinking about it, I'd rather see lvalue slices become a nicer version > > > > of C. > > > > > > > > my @start = (0..5); > > > > my @a = @start; > > > > > > > > @a[1..3] = qw/ a b c d e /; >

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
Dave Whipp wrote: > "Luke Palmer" wrote: > > Benjamin Goldberg wrote: > > > David Storrs wrote: > > > > @a[1..3] = qw/ a b c d e /; > > > > print @a; # 0 a b c d e 4 5 > > > > > > What would happen if I used 1,2,3 instead of 1..3? > > > Would it do the same thing? > > > > Of course. >

Re: Aliasing an array slice

2003-07-18 Thread Dave Whipp
"Luke Palmer" <[EMAIL PROTECTED]> wrote: > Benjamin Goldberg wrote: > > David Storrs wrote: > > > @a[1..3] = qw/ a b c d e /; > > > print @a; # 0 a b c d e 4 5 > > > > What would happen if I used 1,2,3 instead of 1..3? Would it do the same > > thing? > > Of course. I tend to agree, I

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
Luke Palmer wrote: > > > David Storrs wrote: > > > > > > Thinking about it, I'd rather see lvalue slices become a nicer version > > > of C. > > > > > > my @start = (0..5); > > > my @a = @start; > > > > > > @a[1..3] = qw/ a b c d e /; > > > print @a; # 0 a b c d e 4 5 > > >

Re: Aliasing an array slice

2003-07-18 Thread Luke Palmer
> David Storrs wrote: > > > > Thinking about it, I'd rather see lvalue slices become a nicer version > > of C. > > > > my @start = (0..5); > > my @a = @start; > > > > @a[1..3] = qw/ a b c d e /; > > print @a; # 0 a b c d e 4 5 > > What would happen if I used 1,2,3 instead

Re: Aliasing an array slice

2003-07-18 Thread Benjamin Goldberg
David Storrs wrote: > > Thinking about it, I'd rather see lvalue slices become a nicer version > of C. > > my @start = (0..5); > my @a = @start; > > @a[1..3] = qw/ a b c d e /; > print @a; # 0 a b c d e 4 5 What would happen if I used 1,2,3 instead of 1..3? Would it do

Re: Aliasing an array slice

2003-07-09 Thread Austin Hastings
--- David Storrs <[EMAIL PROTECTED]> wrote: > On Tue, Jul 08, 2003 at 05:52:04PM -0700, Austin Hastings wrote: > > > > --- Jonadab the Unsightly One <[EMAIL PROTECTED]> wrote: > > > Am I now thinking clearly? > > > > > I don't think so. > > > > If you've created two separate arrays that happen

Re: Aliasing an array slice

2003-07-09 Thread David Storrs
On Tue, Jul 08, 2003 at 05:52:04PM -0700, Austin Hastings wrote: > > --- Jonadab the Unsightly One <[EMAIL PROTECTED]> wrote: > > Am I now thinking clearly? > > > I don't think so. > > If you've created two separate arrays that happen to start with related > values, then the changes to the first

Re: Aliasing an array slice

2003-07-08 Thread Austin Hastings
--- Jonadab the Unsightly One <[EMAIL PROTECTED]> wrote: > "Jonadab the Unsightly One" <[EMAIL PROTECTED]> writes: > > > Does this imply, though, that it's pointing to specific elements, > > Wow, I wasn't paying attention to what I was thinking there. > Obviously it points to specific elements,

Re: Aliasing an array slice

2003-07-08 Thread Jonadab the Unsightly One
"Jonadab the Unsightly One" <[EMAIL PROTECTED]> writes: > Does this imply, though, that it's pointing to specific elements, Wow, I wasn't paying attention to what I was thinking there. Obviously it points to specific elements, because the subscripts used to create a slice don't have to be sequen

Re: Aliasing an array slice

2003-07-08 Thread Jonadab the Unsightly One
David Storrs <[EMAIL PROTECTED]> writes: > my $r_slice = [EMAIL PROTECTED]; > @$r_slice = qw/ a b c d e /; > print @a; # 0 a b c d e 4 5 This seems right to me. It would take approximately no time to get used to this semantic, IMO. > # Note that it does NOT modify in r

Re: Aliasing an array slice

2003-07-07 Thread David Storrs
Thinking about it, I'd rather see lvalue slices become a nicer version of C. my @start = (0..5); my @a = @start; @a[1..3] = qw/ a b c d e /; print @a; # 0 a b c d e 4 5 # Similarly: @a = @start; my $r_slice = [EMAIL PROTECTED]; @$r_slice = qw/ a b c

Re: Aliasing an array slice

2003-07-06 Thread Dan Brook
On 5 Jul 2003, Luke Palmer wrote: > > return [EMAIL PROTECTED] $begin .. $end ]; > > I fear that this might take a reference to each element in the slice, > rather than a reference to the slice Yes, that would indeed return a list of refs in perl5. Can it also be assumed that the magic hy

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
> > On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: > > > > > Actually, you can't reference a slice! Where the heck does the > > > reference point? I would probably do: > > > > Of course not. I presume it points to something non-existent just like > > a substring reference would in

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
> On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: > > > Actually, you can't reference a slice! Where the heck does the > > reference point? I would probably do: > > Of course not. I presume it points to something non-existent just like > a substring reference would in perl5 :-) >

Re: Aliasing an array slice

2003-07-05 Thread Nicholas Clark
On Sat, Jul 05, 2003 at 09:51:29AM -0600, Luke Palmer wrote: > Actually, you can't reference a slice! Where the heck does the > reference point? I would probably do: Of course not. I presume it points to something non-existent just like a substring reference would in perl5 :-) $ perl -le '$a =

Re: Aliasing an array slice

2003-07-05 Thread Luke Palmer
> On Fri, 4 Jul 2003, Damian Conway wrote: > > > > Will it be possible (or sane even) to bind a variable to an array slice > > It *should* be, since it's possible (if ungainly) to do it in Perl 5: > > Ouch, blatant abuse of perl5's aliasing with @_ and globs ;) Can I also > assume that you can al

Re: Aliasing an array slice

2003-07-04 Thread dbrook
On Fri, 4 Jul 2003, Damian Conway wrote: > > Will it be possible (or sane even) to bind a variable to an array slice > It *should* be, since it's possible (if ungainly) to do it in Perl 5: Ouch, blatant abuse of perl5's aliasing with @_ and globs ;) Can I also assume that you can also pass around

Re: Aliasing an array slice

2003-07-04 Thread Damian Conway
Dan Brook wrote: Will it be possible (or sane even) to bind a variable to an array slice It *should* be, since it's possible (if ungainly) to do it in Perl 5: use Data::Dumper 'Dumper'; @bar = (1,2,3); *foo = (sub [EMAIL PROTECTED])->(@bar[1,0,3]); print Dumper [EMAIL PROTECTED];

Re: Aliasing an array slice

2003-07-04 Thread Luke Palmer
> Will it be possible (or sane even) to bind a variable to an array slice > e.g > > ## correct syntax? > my @array = << a list of values >>; > > my @array_slice := @array[ 1 .. @array.end ]; Yeah, that'll work. It has to, lest: my [EMAIL PROTECTED] := (1, 1, map { $^a + $^b } zip(@fi

Re: $_ aliasing

2002-04-03 Thread Damian Conway
Uri asked: > but what if there are multiple bound variables like this example: > > for %phonebook.kv -> $name, $number { > print "$name: $number\n" > } > > is $_ aliased to either/both/neither of the two topics? are those now > not topics but just aliased variabl

RE: aliasing a value [...]

2001-07-25 Thread Sterin, Ilya
\%foo = \%bar is fine with me, it's the "is alias" I was a little worried about. Ilya -Original Message- From: David L. Nicol To: Sterin, Ilya Cc: 'Davíð Helgason '; '[EMAIL PROTECTED] '; 'John Porter ' Sent: 07/24/2001 5:45 PM Subject: Re:

RE: aliasing a value in a while each loop

2001-07-23 Thread Sterin, Ilya
alias(%foo, %bar) is better IMO since it conforms to other functions in perl. my %foo is alias = %bar; #seems a little out of scope of the language, unless more functionality is implemented in that way. Ilya -Original Message- From: Davíð Helgason To: [EMAIL PROTECTED]; John Porter Sent

Re: aliasing a value in a while each loop

2001-07-20 Thread Eric Roode
David L. Nicol wrote: > >Are there really situations where > > $$reference = An Expression; > >is clearer than > > $reference = \(An Expression); > >? Eric is confused. I don't know about in Perl 6-to-be, but in Perl 5 those two mean totally different things: $foo = \$bar;

Re: aliasing a value in a while each loop

2001-07-20 Thread John Porter
David L. Nicol wrote: > Assignment to a nonexistent reference becomes an > alias instead of a copy. Uh, I dunno. Like Python/Ruby, but without the consistency. I think special constructs -- defined as NOT doing assignment -- should be allowed to set up aliases. This includes, e.g. for(). P

RE: aliasing a value in a while each loop

2001-07-20 Thread Sterin, Ilya
But how would you then copy, without having to bring the reference in existance first. How would you copy period? Maybe I am not understanding, hopefully someone can clear it up:) Ilya -Original Message- From: David L. Nicol To: Mark J. Reed Cc: '[EMAIL PROTECTED] ' Sent: 07/20/2001 1:

Re: aliasing - was:[nice2haveit]

2001-07-19 Thread Me
> Sounds like what we really want is a form of "for" which can iterate > over a list of hashes or arrays: > > for my @a ( @foo, @bar ) { ... > > for my %h ( %foo, %bar ) { ... Yes. Isn't the underlying issue in the above how perl6 handles manipulation and aliasing of multi-dimensional arrays i

Re: aliasing - was:[nice2haveit]

2001-07-19 Thread John Porter
Bart Lateur wrote: > So, in this case, a "with" synonym for "for" would work. > > But this only works for scalars. You can't have a %foo alias to > %Some::Other::hash this way, or a @bar alias to @Some::Other::array. Sounds like what we really want is a form of "for" which can iterate over a lis

RE: aliasing - was:[nice2haveit]

2001-07-19 Thread Sterin, Ilya
Agree. I think that with() should only be used with object references only, and $_ should be set accordingly. Ilya -Original Message- From: John Porter To: [EMAIL PROTECTED] Sent: 07/19/2001 1:01 PM Subject: Re: aliasing - was:[nice2haveit] Sterin, Ilya wrote: > But I thought t

Re: aliasing - was:[nice2haveit]

2001-07-19 Thread John Porter
Sterin, Ilya wrote: > But I thought this was related to more than just with(), so if we have > > ### Would now have to be printed as > > print "This is number "; > print; > print " of 10\n"; > > I still believe that although not defining a variable source will use the > temp variable there is s

RE: aliasing - was:[nice2haveit]

2001-07-19 Thread Sterin, Ilya
cks To: [EMAIL PROTECTED] Sent: 07/19/2001 11:31 AM Subject: Re: aliasing - was:[nice2haveit] > >Then how would you write "I am not a coward" > > with ($foo) > { > print "I am not a"; ##What do I use here or do I have to issue a >#

Re: aliasing - was:[nice2haveit]

2001-07-19 Thread Stuart Rocks
> >Then how would you write "I am not a coward" > > with ($foo) > { > print "I am not a"; ##What do I use here or do I have to issue a >##separate print like... > print; > } > > Ilya Well in Perl5, for the print to use default value it's just 'print;'. The same applie

RE: aliasing - was:[nice2haveit]

2001-07-19 Thread Sterin, Ilya
Stuart Rocks wrote: >> >> C would also make the [variable, alias, whatever] >> default, but not replace the $_: >> >> $_ = "monkey "; >> $foo = "coward"; >> with ($foo){ >> print; >> print "$_"; >> } >> >> would output "monkey coward". >okay, "coward" is default but $_ has not been r

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread Stuart Rocks
> > So, in this case, a "with" synonym for "for" would work. > > > Particularly if '$_' was implied... So with Perl 6's '.' replacing '->', > and 'with' aliasing 'for': > >with ( $XL.{Application}.{ActiveSheet} ) { > .cells(1,1) = "Title"; > .language() = "English"; >} This is m

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread Stuart Rocks
> > So, in this case, a "with" synonym for "for" would work. > > > Particularly if '$_' was implied... So with Perl 6's '.' replacing '->', > and 'with' aliasing 'for': > >with ( $XL.{Application}.{ActiveSheet} ) { > .cells(1,1) = "Title"; > .language() = "English"; >} This is m

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread raptor
>> Does such a thing exist already? > >A WTDI exists already: > >for ( $XL->{Application}->{ActiveSheet} ) { > $_->cells(1,1) = "Title"; > $_->language() = "English"; >} > >(presuming lvalue-methods, of course...) So, in this case, a "with" synonym for "for" would work. ]- OR

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread jh_lists
Bart Lateur wrote: > On Wed, 18 Jul 2001 09:00:25 -0400, John Porter wrote: > >for ( $XL->{Application}->{ActiveSheet} ) { > > $_->cells(1,1) = "Title"; > > $_->language() = "English"; > >} > > > >(presuming lvalue-methods, of course...) > > So, in this case, a "with" s

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread Bart Lateur
On Wed, 18 Jul 2001 09:00:25 -0400, John Porter wrote: >> Does such a thing exist already? > >A WTDI exists already: > >for ( $XL->{Application}->{ActiveSheet} ) { > $_->cells(1,1) = "Title"; > $_->language() = "English"; >} > >(presuming lvalue-methods, of course...) So, in th

Re: aliasing - was:[nice2haveit]

2001-07-18 Thread John Porter
Jeremy Howard wrote: > with $XL->{Application}->{ActiveSheet} { > ->cells(1,1) = "Title" > ->language() = "English" > } > > Does such a thing exist already? A WTDI exists already: for ( $XL->{Application}->{ActiveSheet} ) { $_->cells(1,1) = "Title"; $_->language() =

Re: aliasing - was:[nice2haveit]

2001-07-17 Thread Jeremy Howard
"raptor" <[EMAIL PROTECTED]> wrote: <...> > the idea of aliasing is to preserve the fast access and on the other side to > shorden the "accessor"(i.e the way to access the structure) and make code > clearer.(mostly u can choose a name that has better meaning in your context) > This reminds me... a

Re: aliasing - was:[nice2haveit]

2001-07-17 Thread raptor
> > > I mean something like this : > > > > > instead of : > > > #$Request->{Params} > > > local *myhash = \%{$$Request{Params}}; > > > > > my %myhash alias %{$$Request{Params}};#see - it is my (now as far as I know > > > u can't have it 'my') > > > >You don't need a typeglob there; you can do the