Auto-invariance (WAS: const )

Janice Caron caron800 at googlemail.com
Fri Mar 28 13:19:58 PDT 2008


On 28/03/2008, Sean Kelly <sean at invisibleduck.org> wrote:
>  Here, the need to create separate, identical implementations for the same
>  algorithm that vary only by the constancy of buf simply so the compiler can
>  optimize differently for each aspect is horrible.

Stephen addressed that very problem in the thread "const debacle". He
came up with a solution, which I later simplified. It's probably not
something that will happen any time soon, but just to let you know, it
has been thought about, and a solution proposed.


>  I would much rather have
>  the compiler invisibly generate the different permutations for me and do
>  something fancy with the name mangling to sort out all out invisibly.  So:
>
>  "abc".find( 'b' ); // calls the "invariant(char)[]" permutation
>  char[] buf; buf.find( 'b' ); // calls the "const(char)[]" permutation

Yep, that's what we solved. :-)



More information about the Digitalmars-d mailing list