Help improve error message

Steven Schveighoffer schveiguy at gmail.com
Mon May 8 02:55:57 UTC 2023


On 5/7/23 8:50 PM, ryuukk_ wrote:
> On Sunday, 7 May 2023 at 14:19:49 UTC, Steven Schveighoffer wrote:
> 
>>> Well.. it's not what you expect..
>>
>> Depends ;) I've been using D long enough that it's exactly what I 
>> expected.
> 
> 
> See.. that's were my expectation of this language seems to be 
> non-compatible with the majority of you, and that's super unfortunate 
> because there is nothing i can do to change things
> 
> ``Something`` is a struct, and you are telling me that it is normal for 
> D to treat it as a associative array

No, it's normal that the name `get` when not defined on a type then 
tries UFCS. And because I know `get` is a UFCS function in `object.d`, 
it will pick that up instead of saying "no such function".

What if `Something` had a function called `get`, but it didn't take the 
parameters you sent it? Would it be acceptable to you if it said "no 
function named `get`" instead of detailing why the parameters don't 
match? That's basically what you are asking.

> With that kind of expectation, i now understand better why the .enum DIP 
> got shut down, language is stuck in the past with no way to improve 
> anything, including this type identity crisis

This is unrelated. UFCS is a fabulous feature of the language, and 
understanding the way it works is crucial in order to understand the 
confusing error messages you might see. Not that it's always ideal, but 
I'll take confusing messages and UFCS over the alternative without UFCS 
any day.

FWIW, I was in favor of the enum DIP and think the reasons for rejection 
were invalid. But I've also been here long enough to know when arguing 
over the dead horse isn't worth my time.

-Steve


More information about the Digitalmars-d mailing list