On Friday, 4 December 2015 at 18:21:41 UTC, Walter Bright wrote:
On 12/4/2015 7:11 AM, Jonathan M Davis wrote:
std.container puts linear and/or stable in some of its names and then creates an alias to whichever one makes sense as the default where the alias doesn't have linear or stable in the name. e.g. linearRemove becomes remove via an alias.

Excessive use of aliases is a problem in and of itself - for example, trying to use a debugger with it, or examining the object code.

Oh, I agree. But if we end up with stuff like stableLinearRemove all over the place, it's better to have the aliases than not. However, it's far better IMHO to avoid having all of those long names in the first place.

I suggested in the pseudo namespaces thread using template parameters to express characteristics, as in:

    remove!(stable, linear)

with sensible defaults so most of the time the user would just use:

    remove

Generic code could use the parameters. Another alternative is to have attributes for the algorithm:

    @stable @linear remove() { ... }

and then generic code could test for those attributes.

Either of those would be better than stableLinearRemove or stable.linear.remove. The UDAs would be more documentation friendly, though being able to pass around template arguments could be valuable for the cases where you're trying to enforce specific complexity requirements.

- Jonathan M Davis

Reply via email to