Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^5: Best practice or cargo cult?

by ikegami (Patriarch)
on Jun 20, 2006 at 22:15 UTC ( [id://556536]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Best practice or cargo cult?
in thread Best practice or cargo cult?

I'm not sure what you mean by standard, because I see nothing about the standard usage of x, s and m in perlre.

You changed from "well-known semantics" to "well-known default semantics". My point is that they're not the same. The semantics of ., ^ and $ are not well-known, since they are context-sensitive. The defaults are overriden regularly — more often than not, in my experience — so relying on the default semantics is no good. If you wanted well known semantics in your code, without loss of functionality, it would have to be done through the enforcement of xms.

The problem is that the world on which xms can be enforced is limited, so the "well-known semantics" would only be well-known within that world. However, that's more consistency in semantics than one would enjoy otherwise.

Replies are listed 'Best First'.
Re^6: Best practice or cargo cult?
by dsheroh (Monsignor) on Jun 20, 2006 at 23:02 UTC
    The default semantics are more well-known than any non-default set of semantics. That is the nature of being the default.

    I'm not arguing that the reader of code should blindly assume the default semantics apply in any given case, but rather that there is no cause to request that non-default semantics be applied in cases where the default semantics are more than adequate and, further, that most1 code out there seems to use the default semantics in most1 places. By consistently depending on non-default semantics, you may be more self-consistent, but you are less consistent with the rest of the world.

    1 I suspect that "the vast majority" would be more accurate, but I have no proof that such is the case.

      "Most" is a weasel word. In fact, the opposite has been true in my experience: Among the regexps that use ^, $ or ., at least half required s or m. I don't have a good idea of what the percentage would be if I included those requiring x. I don't know if the rest of the world is in the same boat or not.

      Anyway, I do see your point. There's definitely value in being consistent with the rest of the world, but there must be a point at which world-consistency is outweighed by other concerns. I wonder what it takes.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-19 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found