How will we fix opEquals?

spir denis.spir at gmail.com
Thu Feb 10 16:01:03 PST 2011


On 02/11/2011 12:20 AM, Don wrote:
>> I don't like this idea at all. If the problem is that it's too easy to hide
>> the underlying function without noticing (no compile-time error), then fix
>> how the language treats hidden functions (make it a compile-time error). If
>> opEquals has this problem, other non-language-defined functions will have it
>> too, and fixing it with a special case for opEquals will not fix it
>> elsewhere. Not to speak of the inconsistency it adds.
>>
>
> Oh, I agree. I don't think it's a good idea. It's just the _only_ compromise I
> could see that would actually work.

It seems const is expected to be a rather relevant feature of D2. And to be 
correct (compared to the notion of const in ...), providing true semantic gain 
both for programmers and the compiler, IIUC.
Then, programmers must learn about it, even if they do not intend to use it 
(often, or more than they are forced to).

FWIW, I have stepped on this issue (incorrect signature of opEquals rejected by 
the compiler) 3 times in a few weeks. I was rather annoyed the first time, the 
second time it me let think for a whilet (why is const part of the inherited 
signature, in fact?), and the third time just copied the signature from the 
error message, e basta!
In fact, I end up finding it good the compiler to loudly protest that way, thus 
confronting me with the existence of the feature, letting me explore a it a bit 
even if by myself I wouldn't have done it; this is positive thank to the fact 
the error also provides the means to correct the bug, using a not to obcure 
formulation (for once ;-).

It is, in any case, far better to give programmers a superficial impression of 
the compiler getting on their way from time to time (as long as it's rare), 
than making hidden exceptions to the core semantics of the language just to 
avoid giving such impressions.
Woof, that were more words than I intended to write on the topic, sorry :-)

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d mailing list