opMul

Simen Kjaeraas simen.kjaras at gmail.com
Sat Mar 8 15:11:36 PST 2008


On Sat, 08 Mar 2008 20:00:37 +0100, Janice Caron <caron800 at googlemail.com>  
wrote:

> On 08/03/2008, Dave <Dave_member at pathlink.com> wrote:
>>  Janice, why has it been "shot down" in the past?
>>
>>  Thanks,
>
> Simple answer: Walter either doesn't like it or has more important
> things to work on.
>
> In fairness, this isn't the /only/ idea which has been suggested, and
> I think some people did complain about the extra typing it would need.
> Another suggestion was
>
>     T const f()
>
> (the idea being that const applies to whatever is immediately to its
> right). I do kinda like that one too, but Walter shot that one down,
> primarily I think because it means you can't group multiple functions
> together under a single "const" attribute. The "const(this)" idea
> doesn't suffer from that disadvantage, but it does mean more typing,
> and I think that so long as "the ranks are split", so to speak, then
> there's no compelling reason for Walter to move to any particular
> choice of solution.
>
> ...indeed, I don't think he even acknowledges that there's a problem.
> I recall Walter saying that people will just get used to it (that's
> from memory, not an exact quote - I apologise if I got that wrong), in
> much the same way that we've got used to C++'s const syntax being
> inconsistent.
>
> Personally, I like "const(this)", despite the extra typing, because it
> opens the door for future expansion (e.g "const(outer)" meaning "this
> function will not modify outer").
>
> Dunno if that answers the question or not. Probably not, but I tried.


With trailing const being allowed, I see no problem with T const f(),
and I think it is the most obvious way to write it. For preceding
'const', one logical step would be to allow only const: and const(X):
to be placed in front of functions, and disallow const T f().

-- Simen



More information about the Digitalmars-d mailing list