On 2012.7.30 1:38 PM, Eric Wong wrote:
>> A better solution would be to have path and URL objects which overload
>> the eq operator and automatically stringify canonicalized and escaped.
> Perhaps we can depend on the URI.pm module? It seems to be
> widely-available and not be a significant barrier to installation. On
> the other hand, I don't know its history, either (especially since we're
> now dealing with SVN changes...).
If you want to go down the road of having CPAN dependencies, then it should
definitely be used rather than rolling our own and generating our own bugs.
It's a very commonly needed Perl module.
You'd make a subclass and put any special work arounds for SVN in there.
> Anyways, I don't like relying on operator overloading, it makes code
> harder to read and review.
Right now, canonicalization is a bug generator. Paths and URLs have to be in
the same form when they're compared. This requires meticulous care on the
part of the coder and reviewer to check every comparison. It scatters the
logic for proper comparison all over the code. Redundant logic scattered
around the code is a Bad Thing. It makes it more likely a coder will forget
the logic, or get it wrong, and a human reviewer must be far more vigilant.
Right now I'm pretty sure there's still a ton of bugs.
It also slows things down. As strings, URLs and paths have to be
canonicalized every time they're used or compared. An object representing the
URI or path can cache the canonicalization.
With string comparison overloaded, you'd no longer have to meticulously check
that URLs and paths are always in the same form when they're compared. It
just does it. The logic is in one place. We don't even have to care if one
of them is a string (or which one), it works even if only one half of the
comparison is an object. A new coder to the project doesn't need to know
anything special about URIs and paths, they just treat them as strings.
Finally, they can be slipped into existing code without having to rewrite
Overloaded comparison and stringification can even be used as a tool to find
all the places in the code where URLs and paths are being used, where they're
being turned into strings, and where URL and path manipulation is being done
ad-hoc. For example, if comparison sees one of its arguments as a string, or
if concatenation is used.
The only downside is when chasing down a bug related to canonicalization one
might have to realize that eq is overloaded. But we'd have far less bugs due
to canonicalization. So worth it.
Being faith-based doesn't trump reality.
-- Bruce Sterling
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html