about Apocalypse 5

dada on 2002-06-20T14:43:14

I'm still in the process of swallowing Larry Wall's Apocalypse 5. I lost myself here and there, but I think I got a (blurry) picture. Damian's Synopsis 5 helped a bit.

so I started thinking about it, and I have some concerns to share. it's just my €.02, so feel free to comment about this (and/or beat me on the head) (eventually).

  1. how much stuff are we going to escape in a regex??? Larry has "stolen" three characters (angle brackets and colon) which will need now to be backslashed to be taken literally. but they're so damn common in real world strings! can you imagine what would matching HTML look like? a backslash hell!

    s{<b>(.*?)</b>}{$1}i;       # perl 5
    s:i{\<b\>(.*?)\</b\>}{$1};  # perl 6

  2. the x modifier is the default. well, I have to admit that I've never used it in my code (and I did quite a lot). ok, I get the blame for this. but what about matching strings where spaces do count? consider this:

    /a  [a-z]    [aeiou]/;             # perl 5
    /a<sp><2><[a-z]><sp><4><[aeiou]>/; # perl 6
    # or
    /a<'  '><[a-z]><'    '><[aeiou]>/;
    /a\ \ <[a-z]>\ \ \ \ <[aeiou]>/;

    which one do you prefer?

    I mean, probably having the x modifier the default is a Good Thing after all, but can't we have an option to disable it? aside from the :p5 modifier, which just cuts out a whole world of functionality.

  3. the angle brackets do way too much stuff! let's take again the previous example:

    /a<sp><4><[a-z]><sp><8><[aeiou]>/;

    they're used for: special characters, repetition count, character classes. they're also there for named rules, variables interpolation, and a lot of other things. Larry mentioned 2 problems with the actual regex syntax:

    • Too much reliance on too few metacharacters
    • Different things look too similar

    which is just what I see here.

    I understand that there has to be a balance, but these angle brackets are going to hurt me.

concerns aside, there's a lot of things that I like in the Brave New World of regexp, particularly named rules and grammar support. but I'm afraid it will be a hard, hard time getting used to it :-)