David L. Nicol [EMAIL PROTECTED] wrote:
Yes, exactly. I would like to have a transpose operator, which
will work on a list of hash refs, so this:
$solids = [1..7];
$stripes = [9..15];
foreach (transpose($solids,$stripes));
print the $_-[0] ball is the same color as the $_-[1]\n;
RFC 272
David L. Nicol wrote:
No, that does not work:
Right; I misunderstood what was wanted.
--
John Porter
Stuart Rocks wrote:
CWith 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 replaced, so would not
the
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 applies for alot
From: Stuart Rocks [mailto:[EMAIL PROTECTED]]
Both the following would work:
with($foo){
print I am not a $foo\n;
# or:
print I am not a ;
print;
}
Okay... I've been mostly ignoring this thread. But can someone reiterate the
difference between the above and
for($foo){
Garrett Goebel wrote:
From: Stuart Rocks [mailto:[EMAIL PROTECTED]]
Both the following would work:
with($foo){
print I am not a $foo\n;
# or:
print I am not a ;
print;
}
Okay... I've been mostly ignoring this thread. But can someone reiterate the
difference between the
/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
##separate print like...
print;
}
Ilya
Well in Perl5, for the print to use default
: Garrett Goebel
To: 'Stuart Rocks'; [EMAIL PROTECTED]
Sent: 07/19/2001 12:34 PM
Subject: what's with 'with'? (was: [aliasing - was:[nice2haveit]])
From: Stuart Rocks [mailto:[EMAIL PROTECTED]]
Both the following would work:
with($foo){
print I am not a $foo\n;
# or:
print I am
- was:[nice2haveit]])
Garrett Goebel wrote:
From: Stuart Rocks [mailto:[EMAIL PROTECTED]]
Both the following would work:
with($foo){
print I am not a $foo\n;
# or:
print I am not a ;
print;
}
Okay... I've been mostly ignoring this thread. But can someone
reiterate
I believe what is really wanted is for for to be able to iterate
over lists of arrays or hashes:
for my @i ( @foo, @bar ) { ...
for my %i ( %foo, %bar ) { ...
with real aliasing occuring.
If @_ and %_ are the default iterator variables, then imagine:
for ( @argset1,
Like I am not a
coward which can be easily done with print I am not a $_; will now have
to be written in two separate lines, and possibly more if there is more to
follow.
Ilya
Um, of course the original way is still possible!
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 still a need
To: [EMAIL PROTECTED]
Sent: 07/19/2001 12:59 PM
Subject: Re: what's with 'with'? (was: [aliasing - was:[nice2haveit]])
I believe what is really wanted is for for to be able to iterate
over lists of arrays or hashes:
for my @i ( @foo, @bar ) { ...
for my %i ( %foo, %bar ) { ...
with real
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
But can someone reiterate the
difference between the above and
for($foo){
print I am not a $foo\n;
# or:
print I am not a ;
print;
}
Try this under the current for system, cause it's unclear what will happen
for those new to Perl:
$foo=monkey; $_= coward;
for($foo){
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 list of
- was:[nice2haveit]])
But can someone reiterate the
difference between the above and
for($foo){
print I am not a $foo\n;
# or:
print I am not a ;
print;
}
Try this under the current for system, cause it's unclear what will
happen
for those new to Perl:
$foo=monkey; $_= coward
Sterin, Ilya wrote:
Well then maybe $_ can be a reference to a multidimensional array or hash,
and temp vars can be access like this.
for ( @foo, @bar ) {
print $_-[0] : $_-[1]\n;
}
That's bizarre and unnecessary. We can already do this:
for ( \@foo, \@bar ) {
print $_-[0] :
:)
Ilya
-Original Message-
From: 'John Porter '
To: [EMAIL PROTECTED]
Sent: 07/19/2001 1:46 PM
Subject: Re: what's with 'with'? (was: [aliasing - was:[nice2haveit]])
Sterin, Ilya wrote:
Well then maybe $_ can be a reference to a multidimensional array or
hash,
and temp vars can be access
Why would you want it to print Monkey Hero, I would expect $_ to be
localized, rather than global, which could prove more convenient.
No, it's still localized.
But the With would mean that $_ in a way becomes a normal variable like $foo
was, and the $foo is now the 'default variable'.
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 into
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() = English;
}
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 this case, a with
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 synonym for for would
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
with alias for;
hi,
As I was programming i got again to one thing i alwas needed to have...
especialy when write something fast or debug some result... words comes
about for/foreach and accessing the current-index of the array I'm working
with i.e.
say I have two arrays @a and @b and want to print them
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 my idea for it;
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 my idea for it;
How about
print $a[$_]:$b[$_] for 0..$#a;
or in the p6 case...
print @a[$_]:@b[$_] for 0..$#a;
Ilya
-Original Message-
From: raptor
To: [EMAIL PROTECTED]
Sent: 07/18/2001 12:14 PM
Subject: one more nice2haveit
hi,
As I was programming i got again to one thing i alwas needed
I've go tired of typing :), but if I had current index-iterator ( say under
$i just as example) at hand the way I have $_ i can just type :
print $_ : $b[$i]\n for @a;
OR
print $a[$i] : $b[$i]\n for @a;
For a general solution to this see Buddha Buck's RFC on iterators:
Raptor [EMAIL PROTECTED] wrote:
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 following,
At 05:10 AM 7/17/2001 +, Mark Morgan wrote:
Raptor [EMAIL PROTECTED] wrote:
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
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 following, which does
work
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... another way
Uri Guttman wrote:
one related point is that this symbol table will be accessible via
caller() so you could access/install lexical symbols in a parent block
on the call stack. scary!
Quite. Does anyone have a pointer to tchrist's rant on Tcl's upvar?
--
John Porter
At 03:37 PM 7/16/2001 -0500, David L. Nicol wrote:
Uri Guttman wrote:
one related point is that this symbol table will be accessible via
caller() so you could access/install lexical symbols in a parent block
on the call stack. scary!
We must demand that the feature come with a way to seal
On Mon, Jul 16, 2001 at 03:37:41PM -0500, David L. Nicol wrote:
Uri Guttman wrote:
one related point is that this symbol table will be accessible via
caller() so you could access/install lexical symbols in a parent block
on the call stack. scary!
uri
We must demand that the
On Fri, 13 Jul 2001 20:55:07 +1000 (EST), Damian Conway wrote:
Would you like to clarify what you mean here.
Are you talking about typeglob assignments?
Perl 6 will have:
$Foo::{'$bar'} = \$baz; # Alias $Foo::bar to $baz
Are we back to globals only? What about lexical aliases?
BL == Bart Lateur [EMAIL PROTECTED] writes:
BL On Fri, 13 Jul 2001 20:55:07 +1000 (EST), Damian Conway wrote:
Would you like to clarify what you mean here.
Are you talking about typeglob assignments?
Perl 6 will have:
$Foo::{'$bar'} = \$baz;# Alias $Foo::bar to
$Foo::{'$bar'} = \$baz; # Alias $Foo::bar to $baz
Are we back to globals only? What about lexical aliases? Something
like:
my \%foo = \%bar;
I've always wondered why the backslash operator wasn't lvaluable. (IIRC, C++'s
operator is semi-lvaluable.) IM(V)HO this is
hi,
Two things i think is good to have it :
1. ALIAS keyword.
- first reason is 'cause many people don't know that this is possible.. at
least any newscommer and it will help not to forgot that it exist :).
- Code become more readable.
- can be Overloaded
- the syntax for aliasing can
Two things i think is good to have it :
1. ALIAS keyword.
- first reason is 'cause many people don't know that this is possible.. at
least any newscommer and it will help not to forgot that it exist :).
- Code become more readable.
- can be Overloaded
- the
Two things i think is good to have it :
1. ALIAS keyword.
- first reason is 'cause many people don't know that this is
possible.. at
least any newscommer and it will help not to forgot that it exist
:).
- Code become more readable.
- can be Overloaded
-
-Original Message-
From: raptor
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: 7/13/01 10:19 AM
Subject: Re: nice2haveit
Two things i think is good to have it :
1. ALIAS keyword.
- first reason is 'cause many people don't know that this is
possible.. at
least
At 09:24 PM 7/13/2001 +0300, raptor wrote:
in the case of :
local *myhash = \%{$Request-{Params}};
u do this :
print $myhash{abc};
so it is first clearer and second I hope much faster
Clearer maybe, faster probably not appreciably.
Regardless, the lexical 'symbol table' will be
Subject: Re: nice2haveit
the structure is something like this :
$Request = {
Params = {
abc = 1,
ddd = 2
}
}
the idea is that U don't dereference i.e. :
my $myhash = ($Request-{Params});
if u want to use it U have to do this :
print $$myhash{abc}; #or if u
Yes but can't the same be accomplished with...
my $myhash = (%{$Request-{Params}});
print $myhash{abc};
Though again it copies the structure, I don't see how dereferencing can be
unclear?
]- if u have someting like this anything u can remove in some way is worth
it:))
47 matches
Mail list logo