Complexity nomenclature

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 4 07:22:24 PST 2015


On Friday, 4 December 2015 at 13:59:41 UTC, Andrei Alexandrescu 
wrote:
> On 12/04/2015 01:05 AM, Tofu Ninja wrote:
>> Also maybe a simpler idea would just be to annotate the the 
>> operations
>> with there complexity with UDAs.
>
> Great idea, will keep it in mind. Thanks! -- Andrei

Yeah. If the primary reason to have stable and linear and whatnot 
in the names is so that introspection can be used on them, then 
UDAs will work fine for that. Where it's stickier is if you're 
just calling them in generic code, since then you have no 
protection against the complexity changing when the container 
being used changes. But pretty much no one is going to be wanting 
to use stuff like stableLinearInsert or stable.linear.insert in 
their code instead of insert. So, while having the complexity be 
part of the API has some serious advantages, it's not 
user-friendly for normal use, whereas the UDAs put you somewhere 
in between not having the complexity in the API at all and 
forcing everyone to type out the complexity every time they use a 
function.

- Jonathan M Davis


More information about the Digitalmars-d mailing list