Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1
IchorDev
zxinsworld at gmail.com
Thu Nov 24 14:22:37 UTC 2022
On Wednesday, 23 November 2022 at 15:24:42 UTC, bachmeier wrote:
> I also don't agree that naming things is a hack.
You've overlooked my argument that giving *two names* to *the
same thing* to avoid writing a longer name is a hack. The
compiler knows what type you should enter and so do you? Great,
don't need to write it.
On Wednesday, 23 November 2022 at 15:24:42 UTC, bachmeier wrote:
> Then find a better editor/IDE. One that has copy and paste.
This "helpful advice" does not help at all, it's condescending
and rude.
Not to mention, your argument is completely reversible. If you
don't like ETI because it allows other people to write code
that's not verbose enough for you, then find an editor/IDE that
displays the types anyway.
On Wednesday, 23 November 2022 at 15:24:42 UTC, bachmeier wrote:
> The DIP proposes using the same `$` to refer to *any* enum.
No. `$member` can **only** refer to a member of an enum that
**has to be inferred through context**. Like the type of a
function parameter, or the type of a struct field.
```d
enum A{ a,b,c,d }
enum B{ a,b,c,d }
struct S{ A one; B two; }
void myFn(A param);
void main(){
myFn($a); // passes A.a
S myS = S($c, $d); //myS = S(A.c, B.d);
myS.one = $b; //myS = S(A.b, B.d);
}
```
On Wednesday, 23 November 2022 at 15:24:42 UTC, bachmeier wrote:
> If someone is confused by an explicit name, by definition
> they're going to be confused by a generic `$`.
If the explicit name is a *local alias* that doesn't match what
they expect when using a *library*, causing them to search the
documentation for the *library*, and not for a local alias to
something from that library then yes, it is going to waste their
time.
That's a big issue with reading aliases: that they're identical
to a non-aliased type name, and are generally treated the same
way by programmers and the compiler.
ETI replaces the type identifier with a unique unary operator, so
you can *know* that you *don't know* the type.
More information about the Digitalmars-d
mailing list