Perl's lack of 'in' keyword

Andy Wardley abw at wardley.org
Wed Oct 8 16:08:21 BST 2008


Nigel Rantor wrote:
> Let's take "~~" for example. It's arguably harder to type than "in". And 
> by that I mean for *me* it is harder to type. 

I agree.  ~~ is particularly hard for me to type on keyboards that put it at
the bottom left right next to the shift key (i.e. Macs).  'in' is much easier
to type, and also much easier to read.  Although ~~ is somewhat easier to read
in my head, now that I know it's called "wiggly wiggly".  ;-)

As others have pointed out, '~~' isn't quite the same thing as 'in'.  It would
be potentially confusing in this kind of situation:

     @foo ~~ @bar      # arrays are identical
     @foo in @bar      # not what it looks like!

However, I certainly would be in favour of having an extra 'in' keyword just
for those special cases where it does make sense.  It would be nice if we
could re-use it in for loops, too:

    print $x for $x in @y;

I'm sure it'll be easy to add it in Perl6.

A



More information about the london.pm mailing list