It started off, as most threads do, as a fair innocuous question; I was doing some research for a book I’m working on (more on that soon…) and needed to know about one aspect of Perl 6 regular expression syntax.
It quickly headed off at a tangent, until it was about tuple syntax. Perl has typically been very good at doing what you mean, but that can cause some confusion. Someone noticed that when lists return their length in numeric context, weird things can happen:
(7,8,9) == 3 # true (7,8) == 2 # true (7) == 1 # false () == 0 # true?
Chip Salzenberg quickly pointed out what was wrong with this: Perl 6 was subconsciously appropriating Python’s tuple syntax without its cleanliness of explicit interfaces.
Someone else naturally suggested that adding even more magic would fix the problem. I found myself longing for
@foo.length to do the right thing and for
3 + @foo to be a syntax error.
That’s basically when I realised the pressures of a language designer: lists are the second most fundamental data structure in the language after the scalar, and we’re already proposing adding inscrutable levels of complexity, context-sensitivity and magic to them. This has to be curbed.
But what I was proposing as a solution wasn’t Perl; it was Python. Perl has mutable types and context-sensitivity, and that’s all there is to it; take that away and you’ve got something that isn’t Perl. All these things, however magical and funny they may seem, have been part of Perl since time immemorial - much like when analysing human languages, it’s only when we stop to formalise them that we see the edge cases and the places that the language “doesn’t work”.
Larry’s job is to walk the tightrope between formalisation and approachability, between clarity and ease of use, between regularity and informality. It’s a hard job, and I’m sure he’s thankful for his able assistants; but restructuring and redefining a language that’s prided itself on its unstructured and undefinable nature isn’t the easiest job in the world. No wonder, you might say, the design is taking so long.
How do you think Perl 6 can maintain the approachability of previous versions while being more regular and formalised?
Is it even possible?