RE: Apoc4: Parentheses

2002-01-20 Thread Sterin, Ilya


 
 [EMAIL PROTECTED] writes:
 : QUOTE
 : Interestingly, this one tweak to the whitespace rule also 
 means that we'll 
 : be able to simplify the parentheses out of other similar 
 built-in constructs:
 : 
 : if $foo { ... }
 : elsif $bar { ... }
 : else { ... }
 : 
 : while $more { ... }
 : 
 : for 1..10 { ... }
 : 
 : I think throwing out two required punctuation characters 
 for one required 
 : whitespace is an excellent trade in terms of readability, 
 particularly when 
 : it already matches common practice. (You can still put in 
 the parens if you 
 : want them, of course, just for old times' sake.)
 : /QUOTE
 : 
 : Since the parentheses are no longer required, will the 
 expressions lose or 
 : retain their own scope level?  (I'm assuming that whatever 
 rule applies, it 
 : will hold true if you do elect to use parantheses anyway.)
 
 Yes, you can use a my in those expressions, but now the 
 scope will continue beyond the inner block, whether or not 
 there are parens.

How would we then create a inner block scoped variable, as for counters
or other variables not needed passed the scope.  The only way would be
to increment within the block itself.

Is there a reason why we can't have behavior defined on whether or not
pareths are used.  With pareths it's scope block, without, outter scope?

Ilya



 
 Larry
 



RE: catching warnings

2002-01-08 Thread Sterin, Ilya

Or possibly a universal catch, with the $@.warning and $@.die or
something, so that you can check it.

Ilya

 -Original Message-
 From: David Whipp [mailto:[EMAIL PROTECTED]] 
 Sent: Tuesday, January 08, 2002 7:25 PM
 To: Perl6-Language (E-mail)
 Subject: catching warnings
 
 
 Perl6 is going to introduce a non-resumable throw/catch 
 mechanism to replace die/$@. (I assume that die will be 
 synonymous with throw, for
 compatibility.)
 
 But what about warnings? I frequently find myself wanting to 
 catch warnings (e.g. to add extra context around a 
 library's use of undefined value warning; or to die when a 
 library issues a warning). Its possible to hack this but, as 
 far as I am aware, there is no clean mechanism for resumable 
 exceptions. Could perl6 add such a capability? I don't know 
 what the correct syntax would be, but the pseudo code might look like:
 
 sub foo
 {
   try
   {
 $a = undef + 1 # replace this with something more interesting!
   }
   catch:warn
   {
 print $(datestamp): $@\n;
 resume unless $::warn_count++  10;
 die warning-limit exceeded;
   }
 }
 
 It doesn't have to be in the core language, but it would be 
 nice if it was easy to add as a module.
 
 Dave.
 



RE: ! and !

2001-09-02 Thread Sterin, Ilya



 -Original Message-
 From: Russ Allbery [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, September 02, 2001 8:42 AM
 To: [EMAIL PROTECTED]
 Subject: Re: ! and !


 Bart Lateur [EMAIL PROTECTED] writes:

  Why is it = and not =?

 Because in English, it's less than or equal to not equal to or less
 than, I presume.

  Simply trying to remember the order of characters might be (a bit of) a
  pain. That problem doesn't exist with ! and !.

 Every other programming language I've ever seen uses = and =.  I think

This is Perl.  Why should it be like every other langage?  what happens to
innovation?

 adding additional comparison operators not found in any other language and
 identical to (and harder to type than!) existing operators is a really bad
 idea.

I don't see anything bad about, don't like it don't use it.  I can tell you
quite a few things I don't particularly like in Perl, but what I like is
more than one way of doing things, so I choose my preference.  I can't
recall a langage with unless() either, but sure help is exression writting
sometimes.

Ilya


 --
 Russ Allbery ([EMAIL PROTECTED])
 http://www.eyrie.org/~eagle/



RE: LangSpec: Statements and Blocks [first,last]

2001-09-02 Thread Sterin, Ilya



 -Original Message-
 From: raptor [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, September 02, 2001 1:47 PM
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: Re: LangSpec: Statements and Blocks [first,last]


 hi,

 As we read in Damian Conway- Perl6-notes, there will by a
 var-iterator that
 can be used to see how many times the cycle has been traversed i.e.

 foreach my $el (@ary) {
.. do something 
  print $#;  --- print the index (or print $i )
 }

 shall we have :

 foreach my $el (@ary) {
  print $# if $#.first();  --- print the index on the first iteration

I personally don't like the .first() .last() method implementation, this
means we'll have .second .third, etc...  Why not just check the var iterator
$# == 0, means the first iteration, or have a special var that is not set to
the index, but rather the iteration number 1..end, in case the there is a
way to start iteration at different points.

Ilya


 i.e. 1
.. do something 
  print $# if $#.last();  --- print the index on the first iteration
 i.e. $#ary
 };

 note : we can iterate on something else not only array
 OR :

 foreach my $el (@ary) {
  print $# if first;
.. do something 
  print $# if latest;
 };


 =
 iVAN
 [EMAIL PROTECTED]
 =
 PS. One place where TT is before Perl :)




RE: ! and !

2001-09-01 Thread Sterin, Ilya



 -Original Message-
 From: Russ Allbery [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, September 01, 2001 4:03 PM
 To: [EMAIL PROTECTED]
 Subject: Re: ! and !
 
 
 raptor [EMAIL PROTECTED] writes:
 
  I was looking at Interbase SELECT syntax and saw these two handy
  shortcuts :
 
  operator = {= |  |  | = | = | ! | ! |  | !=}
 
  !  and !
 
 How is ! different from =?

It's just more syntax just like foo != bar 
is the same as (foo  bar || foo  bar).

It might prove convenient to express the expression.

Ilya


 
 -- 
 Russ Allbery ([EMAIL PROTECTED]) 
 http://www.eyrie.org/~eagle/



RE: ! and !

2001-09-01 Thread Sterin, Ilya



 -Original Message-
 From: Andrew Wilson [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, September 01, 2001 6:06 PM
 To: Russ Allbery
 Cc: [EMAIL PROTECTED]
 Subject: Re: ! and !


 On Sat, Sep 01, 2001 at 02:40:40PM -0700, Russ Allbery wrote:
   How is ! different from =?
 
   It's just more syntax just like foo != bar
   is the same as (foo  bar || foo  bar).

 Not if you're using Quantum::SuperPositions ;-)

   It might prove convenient to express the expression.
 
  It's the same number of characters.  How can it be more convenient?

 It may help you to express yourself better in the way that you
 understand the problem you're solving.  Every little bit helps.


That's exactly what I was getting at.  The readability of the program,
otherwise why have more than one way to do it:-)

 cheers

 Andrew



RE: ! and !

2001-09-01 Thread Sterin, Ilya



 -Original Message-
 From: Bryan C. Warnock [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, September 01, 2001 5:59 PM
 To: Russ Allbery; [EMAIL PROTECTED]
 Subject: Re: ! and !


 On Saturday 01 September 2001 05:40 pm, Russ Allbery wrote:
  Sterin, Ilya [EMAIL PROTECTED] writes:
   From: Russ Allbery [mailto:[EMAIL PROTECTED]]
  
   How is ! different from =?
  
   It's just more syntax just like foo != bar
   is the same as (foo  bar || foo  bar).
  
   It might prove convenient to express the expression.
 
  It's the same number of characters.  How can it be more convenient?

 You only have to manipulate the shift key once!  ;-)

 I'm waiting for someone to say that in tri-state logic, '!' != '='

I was actually thinking a similar before I send the initial reply, but I
just can't see a scenerio where it would be easily expressed != :-)

Ilya



 --
 Bryan C. Warnock
 [EMAIL PROTECTED]



RE: HOw to Unsub

2001-08-21 Thread Sterin, Ilya

Usually the generic way is to send email to
[EMAIL PROTECTED], so in your case try
[EMAIL PROTECTED]

Ilya

-Original Message-
From: Patel, Sharad
To: Eric Roode; [EMAIL PROTECTED]
Sent: 08/21/2001 7:22 AM
Subject: HOw to Unsub

HI Guys

Sorry for this but I need to know how to Unsubscribe. Any ideas ??

Regards


-Original Message-
From: Eric Roode [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 21, 2001 2:22 PM
To: [EMAIL PROTECTED]
Subject: Re: explicitly declare closures???


John Porter wrote:

Dave Mitchell wrote:
 ie by default lexicals are only in scope in their own sub, not within
 nested subs - and you have to explicitly 'import' them to use them.

No.  People who write closures know what they're doing.

When's the last time someone accidentally wrote a closure?

People using mod_perl do it all the time:
http://www.perlreference.com/mod_perl/guide/obvious.html

I don't agree with the original proposal, since 'use diagnostics'
will tell you about closures -- but people DO create closures by
mistake, and it can be a very difficult bug to trace if you aren't
used to closures.
 --
 Eric J. Roode[EMAIL PROTECTED]
 Senior Software Engineer, Myxa Corporation


Email Disclaimer

The information in this email is confidential and may be legally
privileged.
It is intended solely for the addressee.  Access to this email by anyone
else 
is unauthorised.
If you are not the intended recipient, any disclosure, copying,
distribution 
or any action taken or omitted to be taken in reliance on it, is
prohibited
and may be unlawful.  When addressed to our clients any opinions or
advice
contained in this email are subject to the terms and conditions
expressed in 
the governing KPMG client engagement letter.



Circular references

2001-08-01 Thread Sterin, Ilya

I was just wondering if there will be any solution for the circular
refernece memory leak (I guess you can call it a problem).  Can't we keep
information on the number of circular references in the SV structure and
then decrement the references count by one + the circular reference count at
the end of scope?

Ilya



RE: Circular references

2001-08-01 Thread Sterin, Ilya

Did really think about that:)
But off the top of my head...

This is only a guess, but 

my $a;
$a = \$a;

A match of two addresses.  Though we are assigning on reference to a scalar,
we can match both addresses?


package CircRef; 

sub new { 
  my $self = []; 
  bless $self, shift; 

  $self-[0] = $self;  # -- circular reference. 
  return $self; 
}

The match of both object would genereate a circular reference.

I guess by doing some extra checking this can be accomplished, just don't
know if 100%, since can't think of other scenerious right now and the above
suggestion might be wrong too:)

But as Dan said, GC will take care of that.  I know that I've read somewhere
before that Python keeps track of it's circular references, so I was sure
there was a way of doing this, just not exactly sure how it was implemented.

Ilya


-Original Message-
From: Buddha Buck
To: Sterin, Ilya; '[EMAIL PROTECTED]'
Sent: 08/01/2001 1:18 PM
Subject: Re: Circular references

At 01:01 PM 08-01-2001 -0600, Sterin, Ilya wrote:
I was just wondering if there will be any solution for the circular
refernece memory leak (I guess you can call it a problem).  Can't we
keep
information on the number of circular references in the SV structure
and
then decrement the references count by one + the circular reference
count at
the end of scope?

Dan has already answered (dead-object detection sweeps by the GC will
take 
care of it), but I'm curious?

How do you detect a circular reference so you can update the circular 
reference count?

Ilya



RE: Circular references

2001-08-01 Thread Sterin, Ilya

 

-Original Message-
From: David L. Nicol
To: Buddha Buck
Cc: Sterin, Ilya; '[EMAIL PROTECTED]'
Sent: 08/01/2001 1:12 PM
Subject: Re: Circular references

Buddha Buck wrote:
 
 At 01:01 PM 08-01-2001 -0600, Sterin, Ilya wrote:
  Can't we keep
 information on the number of circular references in the SV structure
and
 then decrement the references count by one + the circular reference
count at
 the end of scope?
 
 How do you detect a circular reference so you can update the circular
 reference count?
 
 Ilya

Perl6 will only run on quantum computers, didn't you know that?

Then we have all the time in the world:)

I definitelly didn't imply inefficiency by doing the above, which was just
off the top of my head, there are of course better way of eliminating that
problem as with Dan's GC mention.  I never saw circular references leak as a
problem, since I'm used to cleaning up my mess, but it definitelly would be
a problem for others that are only used to programming in interpreted
languages (and then Java).

But no need to further discuss, since that will be taken care off :))

Ilya



-- 
   David Nicol 816.235.1187
 Straight from the docs doesn't mean you can cut-and-paste - it
  just means you find the principle explained clearly - without
 having to construct it from smaller blocks. -- Abigail



RE: Circular references

2001-08-01 Thread Sterin, Ilya

Well guess not, since something like this...

{
  my ($a, $b, $c);

  $a = \$b;
  $b = \$c;
  $c = \$a;
}

would definitelly be hard, resource consuming to implement a circular
reference count.

Ilya

 -Original Message-
 From: Sterin, Ilya [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, August 01, 2001 3:39 PM
 To: 'Buddha Buck '; ''[EMAIL PROTECTED]' '
 Subject: RE: Circular references


 Did really think about that:)
 But off the top of my head...

 This is only a guess, but

 my $a;
 $a = \$a;

 A match of two addresses.  Though we are assigning on reference
 to a scalar,
 we can match both addresses?


 package CircRef;

 sub new {
   my $self = [];
   bless $self, shift;

   $self-[0] = $self;  # -- circular reference.
   return $self;
 }

 The match of both object would genereate a circular reference.

 I guess by doing some extra checking this can be accomplished, just don't
 know if 100%, since can't think of other scenerious right now and
 the above
 suggestion might be wrong too:)

 But as Dan said, GC will take care of that.  I know that I've
 read somewhere
 before that Python keeps track of it's circular references, so I was sure
 there was a way of doing this, just not exactly sure how it was
 implemented.

 Ilya


 -Original Message-
 From: Buddha Buck
 To: Sterin, Ilya; '[EMAIL PROTECTED]'
 Sent: 08/01/2001 1:18 PM
 Subject: Re: Circular references

 At 01:01 PM 08-01-2001 -0600, Sterin, Ilya wrote:
 I was just wondering if there will be any solution for the circular
 refernece memory leak (I guess you can call it a problem).  Can't we
 keep
 information on the number of circular references in the SV structure
 and
 then decrement the references count by one + the circular reference
 count at
 the end of scope?

 Dan has already answered (dead-object detection sweeps by the GC will
 take
 care of it), but I'm curious?

 How do you detect a circular reference so you can update the circular
 reference count?

 Ilya



RE: if then else otherwise ...

2001-07-29 Thread Sterin, Ilya

in ?:: or any other condition checking block, 0 is true, everything else is
false.  I am yet to see why otherwise or any third condition is needed.  If
that's then we can have 4 conditions 1,0,-1,undef, and we can keep going.
That is why there are conditions, if you want to check for -1 you must
specifically do it.

if($foo == 1)
{}
elsif ($foo == -1)
{}
elsif (!$foo)
{}
else
{}

given/when will of course decrease the amount of typing needed.

I know this is a dead issue, but I just can't see how some people actually
see the logic in having three conditions 1,0,-1.  What about -2, -3, etc...
The whole purpose in ?:: is to deferentiate between true or false, weather
it be 1|0 2|0, -1|0, doesn't matter is still true or false.

Ilya

 -Original Message-
 From: raptor [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, July 29, 2001 4:32 PM
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Subject: Re: if then else otherwise ...


  Linguistically, if then else, otherwise doesn't make sense,
 since 'else'
  and 'otherwise' are synonymous.
 ]- ok .. I choosed wrong word... I'm not native English sorry...
 but I agree
 that if-else-otherwise construct is not so good, for most of the
 people... I
 forgot about it already :)

  ? : : suffers from the same problem, just in terms of the ternary ?:
  operator (which of course, wouldn't be ternary anymore) instead of
 English.
  I'm not sure if there will be ambiguity where the standalone colon is
 being
  used elsewhere, but I suspect that it would make parsing more difficult.
  (At least in a BNF grammar.)
 ]- then may be some other way :

 cond ? then : else ~ otherwise;# i don't know

  Regardless of how you perceive the results of = and cmp, it's
 still two
  conditionals.  Something has to make the differentiation
 between positive
  and negative.
 ]- we told trenary not boolean context... is trenary context ok ? we will
 have many more contexts in Perl 6.66 aren't we ];)::

  You're simply asking for another way of writing 'if {} elsif {}
 else {}',
  because you don't like 'elsif'.  Fine.  As has been said before, use a
  switch.
  Still too verbose?  Let's look at your example
 
   $whereCond =  $cond ? ' field  $x AND ' : '' : ' field  $x AND';
   $Query = qq{ SELECT  FROM ... WHERE $whereCond ...};
 
  I think if you specify WHERE you need a clause.
  'SELECT foo FROM bar WHERE' doesn't make sense.
 ]- my mistake sorry. There is ... if u see, so it is more specificaly :

  $whereCond =  $cond ? ' field  $x AND ' : '' : ' field  $x AND';
  $Query = qq{ SELECT  FROM ... WHERE $whereCond field2 =
 (SELECT fieldX
 FROM blah WHERE fieldA = $id )};

 is this way okand this is just example, can figure out some
 other at the
 moment, but that is the reason I'm posting here to see all your
 opinions if
 it is worth it. If (not) I'm ok ( sorry for your time) else (then OK)
 otherwise (will see)  :)

 =
 iVAN
 [EMAIL PROTECTED]
 =

 PS. What type of query to build :

 $qtype = cond ? SELECT : INSERT : UPDATE;

 or I'm building a query for update or insert how to decide how the current
 key - value pair will be used :
 this time we are deciding between  INSERT, UPDATE or UPDATE-WHERE clause :

 $kv .= $qtype ? do {$values .= $v, , $k, } : $k = $v,  :
 $k = $v AND
 ;#is this correct

 later :
 chop,chop...substr..!!
 $query = INSERT INTO blah ( $kv ) VALUES ( $values );
 OR
 $query = UPDATE blah SET $kv WHERE something...;
 OR
 $query = UPDATE ..something... WHERE $kv;

 More examples  :
 =
 index(ref $var, 'A') - 1 ? SCALAR-LVALUE-case : HASH-case : ARRAY-case;
 i.e.
 index(ref $var) - 1 ? $v = $var : $v alias $var : @v = @$var;

 =
 form-field-type ? select : input : textarea;

 =
 output-type ? print-to-web BR : print-to-stdout \n : print-to-STDERR;

 =

 $x = $a = $b ? $a : $default : $b;

 can figure out more at the moment :)



RE: if then else otherwise ...

2001-07-28 Thread Sterin, Ilya

What's the point, you can accomplish the same with if/elsif/else.  Maybe I'm
not understanding this correctly, but

if (cond)
{}
elsif (cond)
{}
else
{}

Ilya

 -Original Message-
 From: raptor [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 28, 2001 9:35 AM
 To: [EMAIL PROTECTED]
 Subject: if then else otherwise ...


 hi,

 we have = and 'cmp' operators but we don't have the conditional
 constroct
 to use better their result :
 May be forthcomming switch will solve this in some way, but isn't
 it better
 to have shortcut like this :

 if (cond)
 { }
 else {}
 otherwise {}


 i.e.
 if cond == 1  then  'then-block'
 if cond == 0  then  'else-block'
 if cond == -1  then  'otherwise-block'

 If the if construct doesn't have otherwise it behave like the current
 if-else..


 =
 iVAN
 [EMAIL PROTECTED]
 =



RE: if then else otherwise ...

2001-07-28 Thread Sterin, Ilya



 -Original Message-
 From: raptor [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 28, 2001 12:32 PM
 To: Sterin, Ilya; [EMAIL PROTECTED]
 Subject: Re: if then else otherwise ...


 I've/m never used/ing elseif ( i hate it :)  from the time I
 have to edit
 a perl script of other person that had 25 pages non-stop if-elsif
 sequence)

I'm lost.  How would you decrease the number of elsif statements with
otherwise???  And as a matter effect the new perl switch construct would
take care of that.  It would be called switch but rather I believe given, if
I remember right.

Ilya


 ... never mind there is two conditions in your example...
 of coruse i've think of this just like a shortcut nothing special
 ... later
 on :

 $x = cond ? $then : $else : $otherwise;#at least this is a good
 shortcut :)


  What's the point, you can accomplish the same with if/elsif/else.  Maybe
 I'm
  not understanding this correctly, but
 
  if (cond)
  {}
  elsif (cond)
  {}
  else
  {}
 
  Ilya




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: aliasing a value [...]

Sterin, Ilya wrote:
 
 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


Is there a problem with the following?  Besides that it doesn't work
like I want it to?  Am I mistaken in believing that it is a clear,
concise and unambiguous way to request assignment of a symbol to
be an alias to another?

my \%foo = \%bar;

(And besides that it extends p5 syntax instead of being apo2-compliant?)

-- 
   David Nicol 816.235.1187
Hush! said the little boy's mother.  But it was too late.  The
emperor's agents had already heard his meek, innocent question and
were rushing through the crowd.  The emperor's agents took the boy
away and he was never, ever, seen or heard from again.



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-25 Thread Sterin, Ilya

Yes, a what you described would work just fine, but I am wondering if just a
loop control variable that can be possibly set at the begining of the loop
which would not necessarily exit the loop, but rather yield kind of a true
or false.

for ($a, $b, $c) (@A, @B, @C) : @B  ### This would assign a true|false 1|0
to control variable when it reaches this loop number.

But I guess incrementing/decrementing the control variable would work just
fine, since it can later be accessed in the loop and to the shortest array.

It can be easily done with a few lines of code without any special vars,
etc..., just by incrementing a counter, while comparing to the shortes
array, but I'm wondering if a control variable would yield other benefits
and if nothing else decrease the amount of written code.

Ilya


-Original Message-
From: David L. Nicol
To: Sterin, Ilya
Cc: Perl 6 Language
Sent: 07/24/2001 6:03 PM
Subject: Re: array/hash manipulation [was :what's with 'with'?]

Sterin, Ilya wrote:

 But now I am trying to figure out, if you are not comparing elements
of the
 array and for example if you need to loop through 3 arrays at the same
time,
 but you need to know, whithin the loop, when the shortest array's last
 element is reached, how would that be accomplished within the loop if
the
 array would just be reset and continue until the longest end is
reached?
 
 Ilya

You have three generator functions that each produce one element at a
time,
and they, and a fourth, flag-checking function (possibly the loop
control variable itself) all have access to a flag that is decremented
by each generator when it starts looping.  For instance, rewrite

for ($c,$d,$e) (@A, @B, @C) { ... };

into something very similar if not exactly like this:



{   
my $arrays_index=0;
while ($arrays_index  @A
and $arrays_index  @B
and $arrays_index  @C){
local (*c, *d, *e) =
($A[$arrays_index % @A],
 $B[$arrays_index % @B],
 $C[$arrays_index % @C]);

...

$arrays_index+=1;
};
};


a workaround of some kind would be required for empty arrays, or
maybe having it die on an empty array is fine.


-- 
   David Nicol 816.235.1187
Hush! said the little boy's mother.  But it was too late.  The
emperor's agents had already heard his meek, innocent question and
were rushing through the crowd.  The emperor's agents took the boy
away and he was never, ever, seen or heard from again.



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: 7/20/01 2:25 PM
Subject: Sv: aliasing a value in a while each loop

John Porter wrote:
 Perhaps a simple
 
 alias( %foo, %bar );
 
 for those times when you really just need a simple WTDI!

Would 

 alias %foo = %bar;

not be ok, 'alias' acting and binding like 'my' of course. Or 

 my %foo is alias = %bar;


No?


/davíð



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-21 Thread Sterin, Ilya



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 21, 2001 5:50 AM
 To: Sterin, Ilya; 'raptor '; Perl 6 Language
 Subject: RE: array/hash manipulation [was :what's with 'with'?]


 Sterin, Ilya [EMAIL PROTECTED] wrote:
  Just one question, how
  would merge behave on two different sized arrays.
 
  @a = (1..5);
  @b = (1..10);
  merge(@a, @b);
 
  ##Would return (1,1,2,2,3,3,4,4,5,5,??
 
  Would it stop on the shortest array.  Couldn't quite find such
 explanation
  in the RFC.
 
 I don't think I specified this in the RFC, since I remember having some
 debates with Damian and others about it that weren't resolved. Now that
 I've had a chance to think about this some more, I think the correct
 behaviour is for the shorter list to reset to the start and continue.

That would be one possible way, but when comparing two array of different
lengths, I guess I would expect undef to compare to the elements of the
longest array that bypassed the length of the shortest array, but that
wouldn't be a problem, just extra code to undef all elements of the shortes
array to equal the length of the longest array.

$shor_arr[$_] = undef for (($#long_arr - $#shor_arr)..$#long_arr);

But now I am trying to figure out, if you are not comparing elements of the
array and for example if you need to loop through 3 arrays at the same time,
but you need to know, whithin the loop, when the shortest array's last
element is reached, how would that be accomplished within the loop if the
array would just be reset and continue until the longest end is reached?


Ilya


It
 is this behaviour that is the source of J and APL's broadcasting
 flexibility. For details see:
   http://www.jsoftware.com/primer/agreement.htm

 --
   Jeremy Howard
   [EMAIL PROTECTED]



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-21 Thread Sterin, Ilya

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, July 21, 2001 5:50 AM
 To: Sterin, Ilya; 'raptor '; Perl 6 Language
 Subject: RE: array/hash manipulation [was :what's with 'with'?]


 Sterin, Ilya [EMAIL PROTECTED] wrote:
  Just one question, how
  would merge behave on two different sized arrays.
 
  @a = (1..5);
  @b = (1..10);
  merge(@a, @b);
 
  ##Would return (1,1,2,2,3,3,4,4,5,5,??
 
  Would it stop on the shortest array.  Couldn't quite find such
 explanation
  in the RFC.
 
 I don't think I specified this in the RFC, since I remember having some
 debates with Damian and others about it that weren't resolved. Now that
 I've had a chance to think about this some more, I think the correct
 behaviour is for the shorter list to reset to the start and continue.

That would be one possible way, but when comparing two array of different
lengths, I guess I would expect undef to compare to the elements of the
longest array that bypassed the length of the shortest array, but that
wouldn't be a problem, just extra code to undef all elements of the shortes
array to equal the length of the longest array.

$shor_arr[$_] = undef for (($#long_arr - $#shor_arr)..$#long_arr);

But now I am trying to figure out, if you are not comparing elements of the
array and for example if you need to loop through 3 arrays at the same time,
but you need to know, whithin the loop, when the shortest array's last
element is reached, how would that be accomplished within the loop if the
array would just be reset and continue until the longest end is reached?


Ilya


It
 is this behaviour that is the source of J and APL's broadcasting
 flexibility. For details see:
   http://www.jsoftware.com/primer/agreement.htm

 --
   Jeremy Howard
   [EMAIL PROTECTED]



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya

Hmmm. Didn't think about that.  That would be a nice way, that way you can
manipulate it's behaviour depending with how many aliases you provide.  

for my $el1, $el2 ( (@foo, @bar) ) {
print $el\n
 }

$el1 and $el2 would of course be aliases, right?

But one though might be, what happens if this is written...

for my $el1, $el2 ( (@foo, @bar, @arr) ) {
print $el\n
 }

Does this bahave in the same way as the first one, but we just don't set
@arr elements, since the user forgot to provide a third alias, or should
this croak at compile time?

Ilya


-Original Message-
From: raptor
To: [EMAIL PROTECTED]
Sent: 07/20/2001 3:37 AM
Subject: Re: array/hash manipulation [was :what's with 'with'?]



 So my initial code (which I modified a little...)

 for ( @foo, @bar ) {
   print $_[0] : $_[1]\n;
 }

 for would set each element of the @_ array to correspond to the
arguments
in
 for() , therfore $_[0] will equal to the current element of @foo and
$_[1]
 will equal to the corresponding element of @bar.  As I mentioned
before
this
 can very easily be accomplished through 0..$#foo loop, but people
disagreed
 based on that it would be a nice option, in my opinion it's useless,
but
if
 was implemented this could be a way:)

]- Yes ... and one more option :

 for my $el1, $el2 ( @foo, @bar ) {
print $el1 : $el2\n
 }

$el1 will get values from @foo and $el2 from @bar, but the following :

 for my $el ( @foo, @bar ) {
print $el\n
 }

will print :
$foo[0]
$bar[0]
$foo[1]
$bar[1]

if people like the other way they can write :

 for my $el ( (@foo, @bar) ) {
print $el\n
 }

will print :
$foo[0]
$foo[1]
...$foo[x]
$bar[0]
$bar[1]


is this correct , but now I'm looking at these too...
http://dev.perl.org/rfc/90.pod
http://dev.perl.org/rfc/91.pod
http://dev.perl.org/rfc/148.pod

so may be what must be the order of passing the arguments and other
stuff
should be done via these proposed functions.

PS. I was thinking of that before, what if we have something let's call
it
'transform' for transformation of any structure to other structure.. but
as
i thought it should combine in some way the features of
switch,if-else,for/foeach, do, while, array/hash-slices, assignment
etc  ps I'm talking about DWIM operator. anyway...
is it
possible to really add such dwim function/operator that can be
modified on
the fly so that it suit all programmers tastes and don't make real
mess...)
... ok i say it :)))
=
iVAN
[EMAIL PROTECTED]
=



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya

It's really not an improvement, but rather a comment, since if aliases and
iterations for numerous arrays were implemented, they would of course have
to somehow behave with hashes, so this would be a bahavior that could be
implemented.

Ilya

-Original Message-
From: Mark J. Reed
To: '[EMAIL PROTECTED] '
Sent: 07/20/2001 11:21 AM
Subject: Re: array/hash manipulation [was :what's with 'with'?]

On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote:
 But this will be flattened, so I would think
 
 for my($key, $val)(%my_hash)
 { ... }
 
 Would be a great convenience.  $key and $val being aliased
accordingly.
I'm sorry, but I fail to see how this is a big improvement over the
current version:

while (my ($key, $val) = each %my_hash)
{ ... }

-- 
Mark J. REED[EMAIL PROTECTED]



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya

No, I don't think you are understanding it correctly.  It's not about
looping sequentially, but rather simultaneouly, for comparison purposes.

@foo = (1,2,3);
@bar = (1,2,3);
for my ($foo, $bar) (@foo, @bar)  #As the index for @foo increases, so 
  #does @bar index
{
print OK\n if $foo == $bar;
}

Will print...
OK
OK
OK

Ilya

-Original Message-
From: Eric Roode
To: [EMAIL PROTECTED]
Sent: 07/20/2001 11:30 AM
Subject: Re: array/hash manipulation [was :what's with 'with'?]

on Fri Jul 20, Mark REED wrote:
I'm sorry, but I fail to see how this is a big improvement over the
current version:

while (my ($key, $val) = each %my_hash)
{ ... }

And a workalike to

 while ( ($a,$b,$c) = (@a, @b, @c) )
or
 for my ($el1, $el2)  (@foo, @bar)
 
is very easy to code in perl 5. At the risk of sounding reactionary,
this doesn't seem like a Big Win for perl.

 --
 Eric J. Roode[EMAIL PROTECTED]
 Senior Software Engineer, Myxa Corporation



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:38 PM
Subject: aliasing a value in a while each loop

Mark J. Reed wrote:
 
 Well, other than the fact that the while(each) doesn't do aliasing.
 Since that would be the whole point, ignore that last message.
 
 On Fri, Jul 20, 2001 at 01:21:57PM -0400, Mark J. Reed wrote:
  On Fri, Jul 20, 2001 at 11:17:13AM -0600, Sterin, Ilya wrote:
   But this will be flattened, so I would think
  
   for my($key, $val)(%my_hash)
   { ... }
  
   Would be a great convenience.  $key and $val being aliased
accordingly.
  I'm sorry, but I fail to see how this is a big improvement over the
  current version:
 
  while (my ($key, $val) = each %my_hash)
  { ... }


 while (my ($key, $$val) = each %my_hash)
 { ... }

and have $val be a reference to the value -- that would be cool,
almost as cool as magic to make $val an alias.  I think the current
behavior is to autoviv ($valeq'SCALAR(0x80f5934)') and copy the
value there.

What I am suggesting is:

(drumroll please) 

  Assignment to a nonexistent reference becomes an
  alias instead of a copy.

It's ugly with current implementations, but with a fully introspective
rewriting interpreter, (i.e. an optimization pass) it could happen?




-- 
   David Nicol 816.235.1187
   Mary had a little chainsaw -- Angus Oblong



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya

Right it can either stop as the shortest list iteration is done, or just set
the corresponding alias to undef.

Don't really know which would be more helpful, since I first need to find a
scenerio where I would use this facility, then what result would I expect
once the shortest list runs out.  Do I still need the values of the longer
list, for one reason or another, or do I want the loop aborted?

Ilya

-Original Message-
From: David L. Nicol
To: Sterin, Ilya
Cc: 'raptor '; '[EMAIL PROTECTED] '
Sent: 07/20/2001 1:44 PM
Subject: Re: array/hash manipulation [was :what's with 'with'?]

Sterin, Ilya wrote:
 
 Hmmm. Didn't think about that.  That would be a nice way, that way you
can
 manipulate it's behaviour depending with how many aliases you provide.
 
 for my $el1, $el2 ( (@foo, @bar) ) {
 print $el\n
  }
 
 $el1 and $el2 would of course be aliases, right?
 
 But one though might be, what happens if this is written...
 
 for my $el1, $el2 ( (@foo, @bar, @arr) ) {
 print $el\n
  }
 
 Does this bahave in the same way as the first one, but we just don't
set
 @arr elements, since the user forgot to provide a third alias, or
should
 this croak at compile time?
 
 Ilya

Given your definition of 

for [list of variables] ([comma-listed arrays]) {...}

I'd consider anything less than a full crash and burn if the number of
variables and the number of arrays did not match to be dangerous.  If
you
want @bar and @arr combined, you could present them as 

for $fooelem, $bar_arr_elem (@foo, (@bar, @arr)) { ...

I would also expect this to stop as soon as the shortest list is out
of elements; also to take other kinds of generators besides
preconstucted
lists in there as the arrays, making the syntax

for [list of N variables] ([list of N generators]) {...}

 
-- 
   David Nicol 816.235.1187
   Mary had a little chainsaw -- Angus Oblong



RE: array/hash manipulation [was :what's with 'with'?]

2001-07-20 Thread Sterin, Ilya



 -Original Message-
 From: Jeremy Howard [mailto:[EMAIL PROTECTED]]
 Sent: Friday, July 20, 2001 8:40 PM
 To: Sterin, Ilya; 'raptor '; [EMAIL PROTECTED]
 Subject: Re: array/hash manipulation [was :what's with 'with'?]


 Sterin, Ilya [EMAIL PROTECTED] wrote:
  Hmmm. Didn't think about that.  That would be a nice way, that
 way you can
  manipulate it's behaviour depending with how many aliases you provide.
 
  for my $el1, $el2 ( (@foo, @bar) ) {
  print $el\n
   }
 
  $el1 and $el2 would of course be aliases, right?
 
 I don't think that this special purpose notation is necessary. With the
 improved 'want' proposed by Damian, the following should be easy
 to achieve:

   @a = (1,2,3,4);
   for ($b,$c) (@a) { print $b $c}
   # prints:
   # 1 2
   # 3 4
   %d = (a=1, b=2);
   for ($b,$c) (@a) { print $b $c}
   # prints:
   # a 1
   # b 2

 Which with the merge() RFC makes the desired behaviour for multiple lists
 easy:

   @a = (1,2);
   @b = (3,4);
   for ($b,$c) merge(@a,@b) { print $b $c}
   # prints:
   # 1 3
   # 2 4

Now this would be cool.  I guess this would be easier to interleave the
arrays, than to implement new ways of calling loops.  Just one question, how
would merge behave on two different sized arrays.

@a = (1..5);
@b = (1..10);
merge(@a, @b);

##Would return (1,1,2,2,3,3,4,4,5,5,??

Would it stop on the shortest array.  Couldn't quite find such explanation
in the RFC.

Ilya




 So, no really new syntax, no special purpose behaviour, just the obvious
 extension of for-iterators to list context, and the introduction
 of one new
 function (which happens to have many other applications).




RE: aliasing - was:[nice2haveit]

2001-07-19 Thread Sterin, Ilya

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 code example print coward monkey

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




RE: aliasing - was:[nice2haveit]

2001-07-19 Thread Sterin, Ilya

But I thought this was related to more than just with(), so if we have

foreach (1..10)
{
print;  

### But if you are trying to use it in a string

print This is number $_ of 10\n;

### Would now have to be printed as

print This is number ;
print;
print  of 10\n;

### Which is three extra statement.  

}

I still believe that although not defining a variable source will use the
temp variable there is still a need for an explicit scalar like $_.
Unless there is something I am missing from this discussion.

Ilya

-Original Message-
From: Stuart Rocks
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
##separate print like...
   print;
 }

 Ilya

Well in Perl5, for the print to use default value it's just 'print;'.
The
same applies for alot (all?) of Perl5 functions. The default value is
always
(as far as I know) $_ or @_ depending on the context.

Both the following would work:

with($foo){
   print I am not a $foo\n;
  # or:
   print I am not a ;
   print;
}

The idea for this style of CWith, came because I don't see why the
default
has to always be $_. Often the amount of code required would be able to
be
dramatically reduced if 'default value'  was userdefinable for blocks
with
the With command.


(All opinions in this post are not representative of Monkey Coward)




RE: what's with 'with'? (was: [aliasing - was:[nice2haveit]])

2001-07-19 Thread Sterin, Ilya

Well if you look at the proposed...

$_ = monkey ; 
 $foo = coward; 
 with ($foo){ 
 print; 
 print $_; 
}

Would print coward monkey, which will give you unexpected results if you
are used to having the same output for both, coward coward.
But I guess the above would not replace $_ which would be very inconvenient
if you had to output it with a whole bunch of other stuff.  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

-Original Message-
From: 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 not a ;
print;
 }

Okay... I've been mostly ignoring this thread. 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;
}

???



RE: what's with 'with'? (was: [aliasing - was:[nice2haveit]])

2001-07-19 Thread Sterin, Ilya

I question this too, since as you mentioned with, in my experience works
nicely to reference and object like
with(object)
{
.foo();
.bar();

}

Ilya

-Original Message-
From: Mark Koopman
To: [EMAIL PROTECTED]
Sent: 07/19/2001 12:42 PM
Subject: Re: what's with 'with'?  (was: [aliasing - 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 the
 difference between the above and
 
 for($foo){
print I am not a $foo\n;
   # or:
print I am not a ;
print;
 }
 
 ???
 
 


pure syntax.  does anyone else question making aliases like 'with' from
'for'?
a 'with' alias could open the door on purely confusing code like this:

with( my $i; $i  10; $i++ ){  ... }

instead of having an standard 'with' that only works on objects like
this:

with( MyObject-new() ) {
  .setIt(blah);
  ...
}





-- 
   -mark koopman

  WebSideStory  10182  Telesis Court
  San Diego CA  92121  858-546-1182 ext 318



RE: what's with 'with'? (was: [aliasing - was:[nice2haveit]])

2001-07-19 Thread Sterin, Ilya

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;
}

As for hashes it might hold the key, also in an multidimensional array.

Ilya

-Original Message-
From: John Porter
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 aliasing occuring.

If @_ and %_ are the default iterator variables, then imagine:

for ( @argset1, @argset2 ) {
quux;

But I'm not convinced of the utility of this over using
scalar references.

-- 
John Porter



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 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 for an explicit scalar like $_.
 Unless there is something I am missing from this discussion.

No.  with() must be consistent with other perl constructs.
If implemented, it will use $_.  Plain and simple.

-- 
John Porter



RE: what's with 'with'? (was: [aliasing - was:[nice2haveit]])

2001-07-19 Thread Sterin, Ilya

Why would you want it to print Monkey Hero, I would expect $_ to be
localized, rather than global, which could prove more convenient.

Ilya

-Original Message-
From: Stuart Rocks
To: [EMAIL PROTECTED]
Sent: 07/19/2001 1:13 PM
Subject: Re: what's with 'with'?  (was: [aliasing - 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;
  for($foo){
print;
$_ =  hero;
  }
  print;

What is printed is monkey coward, rather than monkey hero. In
addition,
$foo is now  hero.

I suppose there isn't a huge difference. Either way, all this talk has
probably taken longer than it would take to write the thing.




RE: what's with 'with'? (was: [aliasing - was:[nice2haveit]])

2001-07-19 Thread Sterin, Ilya

@foo = (foo1, foo2);
@bar = (bar1, bar2);

 for ( \@foo, \@bar ) { 
print $_-[0] : $_-[1]\n; 
  } 

will output

foo1 : foo2
bar1 : bar2

I was thinking more of iterating through them at the same time, which would
sort of like compare them.  I believe this was the initial topic of this
thread (I believe, that was about two days ago, my mind might be going blank
though).

So my initial code (which I modified a little...)

for ( @foo, @bar ) {
  print $_[0] : $_[1]\n;
}

for would set each element of the @_ array to correspond to the arguments in
for() , therfore $_[0] will equal to the current element of @foo and $_[1]
will equal to the corresponding element of @bar.  As I mentioned before this
can very easily be accomplished through 0..$#foo loop, but people disagreed
based on that it would be a nice option, in my opinion it's useless, but if
was implemented this could be a way:)

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 like this.
 
 for ( @foo, @bar ) {
   print $_-[0] : $_-[1]\n;
 }

That's bizarre and unnecessary.  We can already do this:

  for ( \@foo, \@bar ) {
print $_-[0] : $_-[1]\n;
  }

-- 
John Porter



RE: one more nice2haveit

2001-07-18 Thread Sterin, Ilya

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 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 (also say they
are
connected in some way so I want to see them both). In case of one array
I
write :

print $_\n for @a;

fast, simple, goodbut in my case I have to write something like this
:

for ($i = 0; $i  scalar @a; $i++) {
 print $a[$i] : $b[$i]\n
};

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;

isn't that cute :) ... the same count for list in $i I just get current
position in the list. (we can also use pos in some way!!!)

print $_ : $a[$i] : $b[$i]\n for (qw(val1 val2 val3));

I need it very often.:)
don't bother if the lenght of both arrays are different when u use
it, u
know what u are doing...

=
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 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: Curious: - vs .

2001-04-26 Thread Sterin, Ilya

$foo = [$one, $two, $three]; # creates an anonymous list.

$foo = [$object method(foo, bar)];
This would interpret as 

$foo[0] == $object, etc...

Ilya



-Original Message-
From: Buddha Buck [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 26, 2001 11:20 PM
To: Piers Cawley
Cc: Bart Lateur; [EMAIL PROTECTED]
Subject: Re: Curious: - vs .


Piers Cawley [EMAIL PROTECTED] writes:

 Buddha Buck [EMAIL PROTECTED] writes:
 
  Bart Lateur [EMAIL PROTECTED] writes:
  
   On Wed, 25 Apr 2001 15:52:47 -0600 (MDT), Dan Brian wrote:
   So why not
   
 $object!method(foo, bar);
  
  In my opinion, because it doesn't provide sufficient visual
  distinction between $object and method().  At a glance, especially on
  a crowded page, it's similar in appearance to $objectImethod, for
  instance.  $object.method() has a visual separator (although I'd
  prefer $object-method()).
  
  How about borrowing from Objective C?
  
 [$object method(foo, bar)];
 
 How do you create an anonymous list now then? Not that I object to
 borrowing from Objective C you realise.

I thought ($one, $two, $three) was an anonymous list.

Seriously, I hadn't considered that their may be a problem with the
syntax I gave.

How would you, under Perl5, interpret the expression I used.  To me,
it looks like a syntax error.  '$object method(foo,bar)' isn't a
valid method call, so it can't be a ref to an anonymous list of one
value.

Other than severe dependence on the comma, is there any reason why we
couldn't have the following?


$foo  = [$one];   # array ref
$baz  = [$obj,funcall()  ];   # array ref
$quux = [$one,$two,$three];   # array ref
$bar  = [$obj method()   ];   # method call
$bat  = [$one $two $three];   # syntax error



 
 -- 
 Piers Cawley
 www.iterative-software.com