Martin D Kealey wrote:
On Wed, 28 Jul 2010, Darren Duncan wrote:
I think that a general solution here is to accept that there may be more
than one valid way to sort some types, strings especially, and so
operators/routines that do sorting should be customizable in some way so
users can pick the behaviour they want.

The customization could be applied at various levels, such as using an
extra argument or trait for the operator/function that cares about
ordering,

That much I agree wholeheartedly with, but ...

or by using an extra attribute or trait for the types being sorted.

... puts us back where we started: how do we cope if the two endpoints
aren't tagged with the same attribute or trait or locale?

In any case I'd much rather prefer that the behaviour be lexically scoped,
with either adverbs or pragmata, not with the action-at-a-distance that's
caused by tagging something as fundamental as a String.

Lexical scoping *is* a good idea, and I would also imagine that users would frequently apply that at the file or setting level.

But making this a pragma means that the pragma would have to be a little more verbose than a typical pragma.

In the general format, one wouldn't just say, eg:

  collation FooNation;

... but rather it would at least be more like:

  collation Str FooNation;

... to say that you're only applying to operations involving Str types and not, say, Numeric types.

So then, "a" cmp "ส้" is always defined, but users can change the
definition.

I take the opposite approach; it's always undefined (read, unthrown
exception) unless the user tells us how they want it treated. That can be a
command-line switch if necessary.

To paraphrase Dante, "the road to hell is paved with Reasonable Defaults".
Or in programming terms, your reasonable default is the cause of my ugly
work-around.

That might be fair.

But if we're going to do that, then I'd like to go a step further and require some other operators have mandatory config arguments for users to explicitly state the semantics they want, but that once again a lexical pragma can declare this at a higher level.

I'm restating this thought in another thread, "rounding method adverbs", so that's the best place to follow it.

-- Darren Duncan

Reply via email to