Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Capturing parenthesis and grouping square brackets

by hdb (Monsignor)
on Jun 17, 2013 at 23:59 UTC ( [id://1039491]=note: print w/replies, xml ) Need Help??


in reply to Capturing parenthesis and grouping square brackets

Why not go all the way with your proposal?

On a German layout keyboard (QWERTZ), the following characters are inconvenient to type: []{}\|. So your issue not only applies to regexes but to the language as a whole. A proper i18n solution would be required, where the German version would utilize the more accessible characters äöüÄÖÜ and ß instead. I am sure the productivity of the German Perl community would go through the roof. The Pörl community, I mean.

In the meantime, once the developers stop looking at Perl > 5.20 and Perl 6, and get around to implement localized versions of Perl, however called, I would like to advertise the use of UK layout keyboards which have all required characters in convenient locations.

(?: Just my two cents\.)

Replies are listed 'Best First'.
Re^2: Capturing parenthesis and grouping square brackets
by Eily (Monsignor) on Jun 18, 2013 at 00:16 UTC

    The Pörl community actually made me laugh :) . That last comment about asking all of this because I'm lazy wasn't supposed to be taken seriously. If that was really a concern for me I'd write in Python, not Perl. And switching from AZERTY to QWERTY is done easily enough. I do see where the joke went wrong though, it's not obvious that the [ and ] characters are actually extremely simple to type, and just require to hold one key while pressing the other. I should have thought this through.

    My point with this meditation was actually about the unexpected behaviour that parenthesis may lead to in regexes. The only simple is example I could think about was the use of split, but I wondered if it couldn't have other repercussions.

      It is quite telling that you had to resort to split to find an example where the capturing feature of parantheses might lead to unexpected behavior. And how many programs that use split really utilize a regex rather than a simple record separator consisting of one or two characters?

      What is obvious to people and what is not, is far from obvious. Yes, parantheses are used to group items that belong together in expressions, also to express desired precedence. Perl programmers also expect them to capture parts of matches when used in regexes. A Perl beginner will not have problems with that feature most of the time. And my guess is that the beginner will switch from using $3 to $4 rather that using (?:...) (or [...]).

      So from my humble point of view, it is a non-issue. The over-riding principle should be that change involves costs and should be avoided unless the benefits significantly outweight these costs.

        You're certainly right about the fact that my difficulty to find something wrong with this feature speaks for itself. And I actually realized that were there other cases where using parenthesis might be significant (like in a token when you don't know what's in the upper level rules), named captures would make an easy way out.

        So from my humble point of view, it is a non-issue. The over-riding principle should be that change involves costs and should be avoided unless the benefits significantly outweight these costs.

        I'm not going to argue with that, the answers I received helped me see some of the aspects of the matter I might not have grasped on my own, and I do see now that this is indeed little trouble. I can go back to my regexes and be content to not only know how they work, but why it's OK that they work like that :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1039491]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-03-28 23:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found