Perl's lack of 'in' keyword

Nigel Rantor wiggly at
Wed Oct 8 16:26:16 BST 2008

Andy Wardley wrote:
> 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!

Indeed. I missed that initially.

> 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.

Well, I'm quite happy with "foreach [<var>] LIST"...but you're right, 
it'll prolly be in P6.


More information about the mailing list