Re: [nice2haveit]: transpose function

2001-07-25 Thread Jeremy Howard

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 proposes a transpose function:
  http://dev.perl.org/rfc/272.html

Also see the proposal for merge():
  http://dev.perl.org/rfc/90.html





Re: nice2haveit

2001-07-17 Thread Dan Sugalski

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 don't need a typeglob there; you can do the following, which does work
>with 'my':
>
>my %myhash = %{$Request->{Params}};

Originally he wanted an alias, and that won't do it. You'll flatten and 
unflatten, and changes to %myhash won't be reflected in the original.

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: nice2haveit

2001-07-17 Thread Mark Morgan

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, which does work
with 'my':

my %myhash = %{$Request->{Params}};

or 

my $hashref = $Request->{Params}; # neater, and I personally prefer
  # working with 
hashrefs

Less typing, and it's already in there. :)

Take care,
Mark.



Re: nice2haveit

2001-07-16 Thread Paul Johnson

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 feature come with a way to seal the current
> context from manipulation, even possibly a way to block accesses.

Doesn't sound very Perlish to me.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net



Re: nice2haveit

2001-07-16 Thread Dan Sugalski

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 the current
>context from manipulation, even possibly a way to block accesses.

Demand away, but you're not likely to get it.

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: nice2haveit

2001-07-16 Thread John Porter

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




Re: nice2haveit

2001-07-14 Thread Brent Royal-Gordon

> > $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 a good idea--it certainly makes more 
sense than $Foo::{'$bar'} = \$baz.  Or wait, was that supposed to be %Foo::{'$bar'}?  
:^) )
-- 

___
Get your free email from http://webmail.earthlink.net




Re: nice2haveit

2001-07-14 Thread Uri Guttman

> "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 $baz

  BL> Are we back to "globals only"? What about lexical aliases? Something
  BL> like:

  BL>   my \%foo = \%bar;

  BL> (Now %foo is an alias to %bar.)

what damian has been showing as a possible/probably solution is a
lexical scoped symbol table called %MY::. it would be available inside
any block scope and allow you to alias things just like the above:

 $MY::{'$bar'} = \$baz; # Alias lexical $bar to $baz

now $bar is lexical and aliased to $baz

i like the concept but i worry about the overhead of setting up %MY. i
assume it will only be created if it is referred to in the block. there
may be other optimizations.

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

-- 
Uri Guttman  -  [EMAIL PROTECTED]  --  http://www.sysarch.com
SYStems ARCHitecture and Stem Development -- http://www.stemsystems.com
Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11
Class and Registration info: http://www.sysarch.com/perl/OOP_class.html



Re: nice2haveit

2001-07-14 Thread Bart Lateur

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? Something
like:

my \%foo = \%bar;

(Now %foo is an alias to %bar.)

-- 
Bart.



Re: nice2haveit

2001-07-13 Thread raptor

> 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:))

$tables{$$self{rel}{$k}{table}}[0][VALS]
or this :
$$params{$$self{rel}{$k}{names}[$t].$j}

especialy if U have a couple of this :") in 3-4 rows of code...

=
iVAN
[EMAIL PROTECTED]
=








RE: nice2haveit

2001-07-13 Thread Sterin, Ilya

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?

Ilya

-Original Message-
From: raptor
To: [EMAIL PROTECTED]; Sterin, Ilya
Sent: 7/13/01 12:24 PM
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 preffer  print $myhash->{abc}

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 

=
iVAN
[EMAIL PROTECTED]
=



Re: nice2haveit

2001-07-13 Thread Dan Sugalski

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 available to perl programs. 
How is up in the air, but I've heard proposals that the virtual package MY 
will refer to it.

We'll see, once Larry formalizes (or squashes) the idea.

Dan

--"it's like this"---
Dan Sugalski  even samurai
[EMAIL PROTECTED] have teddy bears and even
  teddy bears get drunk




Re: nice2haveit

2001-07-13 Thread raptor

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 preffer  print $myhash->{abc}

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 

=
iVAN
[EMAIL PROTECTED]
=




RE: nice2haveit

2001-07-13 Thread Sterin, Ilya

 

-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 any newscommer and it will help not to forgot that it exist
:").
>>  - Code become more readable.
>>  - can be Overloaded
>>  - the syntax for aliasing can become reicher :")
>
> 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
]-  Can I see more examples of typeglob assignment somewhere ? link ?

>I mean something like this :

>instead of :
>#$Request->{Params}
>local *myhash = \%{$$Request{Params}};

Wouldn't that do the same as 

my $myhash = ($request{Params});

I know that is actually copying value, but I believe the above does too?

Ilya


>my %myhash alias %{$$Request{Params}};#see - it is my (now as far as I
>know
>u can't have it 'my')

>=
>iVAN
>[EMAIL PROTECTED]
>=







Re: nice2haveit

2001-07-13 Thread raptor

>> 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 become reicher :")
>
> 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
]-  Can I see more examples of typeglob assignment somewhere ? link ?

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')

=
iVAN
[EMAIL PROTECTED]
=








Re: nice2haveit

2001-07-13 Thread Damian Conway

   > 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 become reicher :")

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


   > 3. For this I'm not totaly sure, but it comes to my mind many modules
   > uses notation like this to pass params i.e.
   > 
   > someFunc ( -param1 => 'blah', param2 => 'xxx' .)
   > 
   > Why not have %_ in our case we have the following elements :

http://dev.perl.org/rfc/128.html#Named_arguments

Damian