Discussion Thread: DIP 1044--Enum Type Inference--Community Review Round 1
Timon Gehr
timon.gehr at gmx.ch
Sun Nov 20 09:56:04 UTC 2022
On 19.11.22 05:14, Walter Bright wrote:
>
> You're referring, of course, to the "contextual" part of the DIP, where
> the lookup works only in a subset of cases. The contextual lookup can
> result in some odd cases like:
>
> ---- module A ----
> private enum E { e; };
> public void dra(E);
> ------------------
> import A;
>
> dra($e);
> ------------------
> ...
This is a good point. However, it's an existing oddity in the language
that public symbols can use private symbols in their signatures.
> Is that a good thing?
I think contextual lookup is better than trying to do a lookup within
the scopes of all visible enumerations. Vladimir's suggestion where we
would add symbol literals is even better.
I have somewhat mixed feelings about implicit `with`. On one hand, it's
even more convenient than `$e` `_.e`, `:e` etc, but on the other hand
it's even less predictable for a user where it will work, and it can
shadow variables from outer scopes (which is also a breaking change).
> I'm not sure. This is also not addressed in the DIP.
I don't have particularly strong feelings about this feature either way,
but it is quite popular and I have been annoyed by the need to write
`with` statements in the past. (But maybe that's partly because the
emacs d mode is not so great at indenting
switch(x) with(E){
case a: ...
}.)
More information about the Digitalmars-d
mailing list