const property don't wont return const reference to value
monarch_dodra
monarchdodra at gmail.com
Mon Dec 24 05:32:55 PST 2012
On Sunday, 23 December 2012 at 15:05:16 UTC, Namespace wrote:
> On Sunday, 23 December 2012 at 14:55:30 UTC, bearophile wrote:
>> Namespace:
>>
>>> Shouldn't we fix this? Most of the Newcomer are confused with
>>> the fact,
>>
>> Take a look in bugzilla. I opened an enhancement request to
>> fix this situation, but Walter has closed it down. The
>> rationale is to keep uniform the way D manages tags like
>> const, immutable, etc.
>>
>> I don't agree with him in this case: I agree that uniformity
>> is good, but breaking symmetry is acceptable when it just
>> produces an error and when it helps avoid a common mistake.
>>
>> If you have strong desires about fixing this, then I suggest
>> you to open a new thread about it in the main D newsgroup. I
>> have already fought this battle and I lost. (And I think this
>> time Jonathan was on my side).
>>
>> Bye,
>> bearophile
>
> I have to write "const (ReturnType)" and "ref ReturnType" ...
> very symetric. But I think that Walter thinks that this is the
> best idea, and of course better than that what C++ and other
> languages do. So what should I waste my time with "war" with
> my limited english knowledge ? ;)
> But thank you, that you tried it.
>
> Maybe this is something for Romulus... :)
"ref" is a function qualifier, not a type qualifier, so you could
even write it as:
"const(ReturnType) foo() const ref;"
So technically, it is symetric.
I for one don't think this is a huge problem. There is *some*
confusion for those comming from C++, but they (we) have to learn
D is not C++. Besides, I like the liberty of putting all
qualifiers on the line before the types, including const.
If anything "const" *itself* is VERY confusing for new commers.
WAY more than the syntax used to qualify a function with it.
More information about the Digitalmars-d-learn
mailing list