any news on const/invariant?

Derek Parnell derek at nomail.afraid.org
Wed Nov 28 20:15:20 PST 2007


On Wed, 28 Nov 2007 23:02:06 -0500, Steven Schveighoffer wrote:

> If that method returns a const type, then the method is declared as:
> 
> const const(Type) f();
 
> To someone who never used const before in another language, this isn't any 
> less or more intuitive than the way C++ does it.  It's like saying using 
> semicolons at the end of statements is intuitive.  It's just a different way 
> of expressing what you want to the compiler.

Got it. When I see two adjacent "const" keywords I need to realize that the
first const refers to the second 'thing' and the second const refers to the
first 'thing'. Very intuitive.

However ... what if we tried to make things unintuitive ... like having the
first const refer to the first thing and the second const refer to the
second const ... Nah ... on second thoughts that would only confuse people.
Who'd ever work out that ...

 const(Type) const f();

means that the 'Type' is const and the f() is also const?

-- 
Derek
(skype: derek.j.parnell)
Melbourne, Australia
29/11/2007 3:07:14 PM



More information about the Digitalmars-d mailing list