Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Best practice or cargo cult?

by dsheroh (Parson)
on Jun 20, 2006 at 18:31 UTC ( #556503=note: print w/ replies, xml ) Need Help??


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

That's why I said "the real question is whether the style was created with thought"

In that case, I misunderstood whose thought you were referring to and had taken you mean the originator of the coding style rather than the one using it.

When there are defined standards and well-known semantics, I'd love to here about them.

The defined standard is documented in perlre and the well-known default semantics are those which are used in the absence of any modifiers. There are certainly times when the default semantics need to be changed, thus the standard includes modifiers such as /s to alter them, but this does not change my original point that it is generally better to stick with the default (no modifiers) semantics where possible and only invoke modified semantics when there is a need to do so.


Comment on Re^4: Best practice or cargo cult?
Download Code
Re^5: Best practice or cargo cult?
by ikegami (Pope) on Jun 20, 2006 at 22:15 UTC

    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.

      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
Node Status?
node history
Node Type: note [id://556503]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (16)
As of 2014-09-19 13:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (138 votes), past polls