Perl's lack of 'in' keyword

Andy Wardley abw at wardley.org
Thu Oct 9 08:36:58 BST 2008


Paul LeoNerd Evans wrote:
>   my $foo = $a + $b;

The meaning of '+' is already known to most people so there's no cognitive
overhead there.

> One of the things _I_ like about Perl is that it accepts the fact that
> larger alphabets yield shorter sentences.

I get what you're saying, and agree to some extent.  But you've missed out the
words from the linguistic analogy.

Larger alphabets like Japanese, for example, do indeed yield shorter
sentences.  However, they are inscrutable to anyone who hasn't spent several
years studying the characters in the alphabet to learn what they all mean.

Languages with smaller alphabets like English and other Latin-derived
languages are also able to yield small sentences, but they do so by having
large lexicons.  Instead of inventing new characters to represent new
concepts, we take the existing alphabet and make new wordicles and
speaklets from them, quite noproblematically.  In the extreme case,
languages like German are fromseveralwordswholesentencemakers (*cough*
Java *cough*).

So shorter sentences are yielded by having symbols that represent semantic
concepts that are otherwise difficult to express by the fact that they require
more elaborate sentence construction.  Or, more succinctly: symbols confer
meaning.  The number of character in the symbol and the  alphabet in which it
is written are less important than the fact that it exists in the first place.

What this comes down to is that "@a ~~ @b" and "@a like @b" (for example)
are both significantly shorter than writing out the equivalent code in full.
The fact that "like" is 2 characters (but only one keypress) longer than '~~'
is, to me, largely irrelevant because I've reduced a whole block of messy code
into one expression comprised of a mere 3 symbols.

I'm sure that in time my branebox will come to recognise '~~' and "just read
it" the way that it currently "just reads" the word "like" and knows what
it means.  But even then, I might still prefer to write "like" (or "matches"
or something similar) for the sake of any other non-Perl6 speaking visitors
I might have dropping in on my code.  It reads like a sentence instead of
looking like a graffiti tag.

> Perl isn't afraid to use
> symbols if it means they tend to give shorter statements that are quicker
> to read or write.

I like short too.  Succinct is good, but cryptic isn't.  IMHO, Perl should
be choosing more words for those symbols instead of choosing new letters to
add to the alphabet.

YMMV, of course.

A



More information about the london.pm mailing list