opMul

Simen Kjaeraas simen.kjaras at gmail.com
Thu Mar 6 02:50:53 PST 2008


On Thu, 06 Mar 2008 11:29:33 +0100, Koroskin Denis <2korden+dmd at gmail.com>  
wrote:

> On Thu, 06 Mar 2008 03:04:39 +0300, Bill Baxter  
> <dnewsgroup at billbaxter.com> wrote:
>
>> Denton Cockburn wrote:
>>> Yep, that did the trick.
>>>
>>> IIRC, the const in front means const(this)
>>>
>>
>> and apparently const at the end means that too, now.
>>
>>         Foo opMul(const Foo [b]) const  { // also ok
>>                ...
>>          }
>>
>>
>> --bb
>
>
> This syntax looks less confusing to me. Why keep both?


I agree. With const foo x; meaning x is const, const foo y(){} meaning y  
is const... wait, this actually does seem to make sense when you look at  
it like that.

Better way to think of it: const foo x; is the same as const(foo) x;.  
Thus, const foo y(){}; should also mean const(foo) y(){};.

Going with how D const should apply to whatever is directly after it, foo  
const y(){}; appears to me the most logical way of writing it. Trailing  
const is also acceptable to me, seeing as there's nothing else that const  
could refer to.

-- Simen



More information about the Digitalmars-d mailing list