any news on const/invariant?

Derek Parnell derek at psych.ward
Wed Nov 28 13:20:31 PST 2007


On Wed, 28 Nov 2007 20:33:20 +0000, Janice Caron wrote:

> My objection to the existing syntax is more or less solely that
>     const int f();
> 
> does not declare that f returns a const int, and I think that all
> newcomers to D will find that /hugely/ confusing.

The simple fact is that 

   const type funcname();

looks ambiguous. It LOOKS like it could mean either that funcname() returns
a const type OR that funcname() is const but returns a non-const type.

Once you know the rules you can workout what is intended, but it is not as
intuitive as you might like it to be.

Will it really be so hard to provide syntax that is not so ambiguous?

Also, what is the syntax for a const function that returns a const type?

   const (const type) funcname();  ????
   const const type funcname(); ???
   const (const type funcname)(); ???
   const (const type funcname()); ???

Walter, your efforts to achieve simplicity are being thwarted by the
results being simplistic.


The D programming language has way too much keyword overloading to make it
an easy language to learn and remember.

-- 
Derek Parnell
Melbourne, Australia
skype: derek.j.parnell



More information about the Digitalmars-d mailing list