Return by 'ref' problems...

Jacob Carlborg doob at me.com
Fri May 4 13:00:09 PDT 2012


On 2012-05-04 17:55, Jakob Ovrum wrote:
> On Friday, 4 May 2012 at 15:49:03 UTC, Manu wrote:
>> It's very counter intuitive to mark the _function_ ref, rather than it's
>> return type.
>
> It is a function attribute, so it makes perfect sense. The rest is an
> issue of documentation/education.
>
> I agree it may not be optimally intuitive, but I don't see any superior
> syntactic options.

ref int a ();
const int b ();
const(int) c ();

"a" is function returning an int by reference.
"b" is a const function returning an int.
"c" is a function returning a const int.

Don't you see how it's confusing. Perhaps it would be better if "a" was 
declared like this:

ref(int) a ();

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list