HN user

bza

23 karma
Posts1
Comments9
View on HN

This technique is unreliable in practice, and the author's discussion is confused.

First, their explanation doesn't make sense. They're supposing that there's some determinacy in the order in which a matcher can be expected to examine the different possible matches. But that's provably not the case: if it were, then deterministic and non-determinsitic finite automata would be inequivalent.

But the technique in question does seem to require some determinacy as to which of several alternatives will match against a string. Where does that determinacy come from? The semantics of the alternation operator (the '|') as usually formulated don't specify any preference among alternations. For that reason, POSIX additionally requires that a matcher return the longest possible match (and if there are several such, the leftmost is what must be returned). Where you do find an explicit guarantee concerning which of several different possible ways of matching will be preferred, it's almost certainly because the engine is aiming at POSIX compliance.

Such compliance has a significant cost, though, as it requires the matcher to consider all possible matches (in order to find the largest). For that reason, most regex engines forego strict POSIX compliance and only guarantee that some match will be returned if one exists, not that that match will be the leftmost longest. Some engines offer the option of requesting strict POSIX behavior, but the default will always be to eagerly return the first match encountered (and recall the point above that there provably can't be a guarantee about the order in which matches are encountered, in general).

You should never do this in production code unless you're sure that your matcher is POSIX-compliant.

It's not physics woo; the way the OP's using "duality" is common among mathematicians and physicists. The different types of duality listed in the physics and math sections of the Wikipedia article you linked to are thought of, by typical practitioners in these areas, as all being instances of a more general phenomenon. That's why these various things end up being called dualities.

That generic kind of duality is well described in the first sentence of [1], and the OP's explanation of a duality as "a connection between two things where the properties of one defines the properties of the other" is pretty obviously an attempt to convey, to a lay audience, that sense of duality.

[1] http://en.wikipedia.org/wiki/Duality_(mathematics)

This is the trade off we pay for lower taxes.

Why would mandating that companies provide meaningful maternity or paternity leave require higher taxes? This topic doesn't have much to do with fiscal policy.

Whether a system is tightly coupled is independent of whether it's implemented as a single process. Objections to systemd as monolithic, as constituting a single point of failure, etc. are based on its being a tightly coupled set of components.

Emacs, naked 13 years ago

The current policy (as enunciated by Stefan Monnier, who took over as maintainer from RMS a few years ago) is for new packages to be added to the package archive unless there's a very strong argument for their providing core functionality. (Packages that already ship with Emacs are unlikely to be removed from the core, though.)