Re: Hyper-operators and Underscore

2001-10-06 Thread Erik Lechak




Bryan,

I guess my biggest complaint was that underscore would be the only single
character operator that would be in danger of  being lumped into the variable
name.  I forgot about  x .  I use it all the time.  If  x  has that constraint
why not the underscore.  I worked at a place where
variables_with_names_like_this_were_common. You can see why I have reservations
about the overuse of underscores.

And about that "shifted" question.  I guess I am drinking ways too much Mountain
Dew.  I was thinking shift as in pop as opposed to shift as in keyboard.  Sorry.

Erik Lechak


Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97



Re: Hyper-operators and Underscore

2001-10-06 Thread Erik Lechak


Thanks for the info,


Bryan,

Thank you for the info.  I am more engineer than computer scientist, so
please excuse the ignorance behind these questions.


>
> Except that the operator truly is simply an underscore.  But it's also a
> valid identifier character, so where it may be confused with that, you are
> simply required to make it less ambiguous to the parser.
>
> $a _= $b _ $c;  # $a _= $b _$c;
> ${a}_=${b}_$c;
> %h{$s}_="Hello, "_"world!\n";
>
> As Larry said, no different that the other operators that also consist of
> valid character identifiers.

I understand that the operator is just the underscore.  However, in the third
edition of the camel book on page 49, the second paragraph, it states that "An
identifier is a token that starts with a letter or underscore and contains only
letters, digits, and underscores."   Since there are no singel letter operators,
no single digit operators, but now we see the advent of the underscore operator,
it follows that the underscore will be the only operator that could be confused
as part of the variable name.

1) My question is what other operator could be confused with an identifier?

2) Where did Larry say "no different that the other operators that also consist
of valid character identifiers." ?



>
> IIRC, '^' was considered earlier.  (And it's shifted, BTW.)
>

3) What do you mean by shifted?


Thank you ,
Erik Lechak



Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97



Hyper-operators and Underscore

2001-10-06 Thread Erik Lechak
,3,4,5);
 my @y=(2,3,4,5,6);
 my @z=(4,5,6,7,8);

 my @result;
 my $index = 0;

 for my $x (@x){
  push(@result,$x+$y[$index]+$z[$index]);
  $index++;
 }

All of that just to add these three arrays together.  You can see that
the auto index variable "$#" would make life easier.

 my @x=(1,2,3,4,5);
 my @y=(2,3,4,5,6);
 my @z=(4,5,6,7,8);

 my @result;

 for my $x (@x){
  push(@result,$x+$y[$#]+$z[$#]);
 }

Easier, but not by much.


Then I thought for a while.  Now this is only someplace to start and I
am sure that someone can think of something better.  I got the idea
while thinking of the semicolon in the c-style "for" statement.

What if you could do this:

 my @x=(1,2,3,4,5);
 my @y=(2,3,4,5,6);
 my @z=(4,5,6,7,8);

 my @result;

 for my ($x,$y,$z) (@x;@y;@z){
  push(@result,$x+$y+$z);
 }


and if you could do that why not this:


 my @x=(1,2,3,4,5);
 my @y=(2,3,4,5,6);
 my @z=(4,5,6,7,8);

 my @result=map{ $_[0] + $_[1] + $_[2]} (@x;@y;@z);

..  OR ..

 my @result=map{ shift + shift + shift} (@x;@y;@z);


This may provide a more powerful solution to the problem than
hyper-operators.  But may be more difficult to parse or code.


Erik Lechak
[EMAIL PROTECTED]




















Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97