The fact that something can be accomplished in Perl doesn't necessarily mean 
its the best or most desirable way to do it. I respect the programming 
abilities, but

   grep { ref($a) eq ref($b) } @b)

is far less intuitive than the proposal. I could perhaps dig into my distant 
memory and explain how to accomplish something like this with PDP-8 
front-panel switches, but that doesn't mean that we should not attempt a 
loftier solution.

IMHO Perl should add a plethora of higher-order functions for arrays and 
hashes, and from the chatter here I think a lot of people agree. Put them 
there and if people don't want to use them, fine. Give us lots of ways to do 
things- we know that's Perlish.

Personally, I don't like the "in" choice- I favor symbols over words, but 
its better than not having it at all. Conflicts with barewords, especially 
in hash refs, can be a problem. Do away that the conflict by favoring 
symbols over words.

Ed

---------------------------------------------------------------------


>From: Garrett Goebel <[EMAIL PROTECTED]>
>To: 'Jonas Liljegren' <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
>Subject: RE: $a in @b
>Date: Wed, 6 Sep 2000 09:43:03 -0500
>
>From: Jonas Liljegren [mailto:[EMAIL PROTECTED]]
> >
> > Does any other RFC give the equivalent to an 'in' operator?
> >
> > I have a couple of times noticed that beginners in programming want to
> > write if( $a eq ($b or $c or $d)){...} and expects it to mean
> > if( $a eq $b or $a eq $c or $a eq $d ){...}.
> >
> > I think it's a natural human reaction to not be repetative. An 'in'
> > operator will help here. It could be something like this:
> >
> >     $a in @b; # Has @b any element exactly the same as $a
> >     $a == in @b; # Is any element numericaly the same as $a
> >     $a eq in @b;
> >     $a > in @b;  # Is $a bigger than any element in @b?
> >     $a not in @b; # Yes. Make 'not' context dependent modifier for in.
>
>       grep { ref($a) eq ref($b) } @b)  # Same type?
>       grep { $a == $_ } @b)
>       grep { $a eq $_ } @b)
>       grep { $a > $_ } @b)
>       (grep { $a != $_ } @b) == @b)
>
>Garrett

_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at 
http://profiles.msn.com.

Reply via email to