No we should not support enum types derived from strings
Paul Backus
snarwin at gmail.com
Wed May 12 23:31:21 UTC 2021
On Wednesday, 12 May 2021 at 23:08:24 UTC, deadalnix wrote:
> Now, with enum string, there is an interesting twist, because
> they can be passed at compile time too. in theory, that should
> not change anything when it comes to the LSP, but in practice,
> it seems like it does, which is IMO where the root of the
> problem is.
>
> Consider:
>
> string format(string S, A...)(A args);
>
> While S is a compile time parameter, it is not a type
> parameter, but a value parameter. In that case, it is expected
> as per the LSP that I can pass down string, or any subtype of
> strings as the first compile time parameter of format, and this
> ought to work as expected.
This *does* work as expected: https://run.dlang.io/is/Ru9phk
The issue with `format` is that it takes an alias parameter, not
a value parameter--and the reason it does *that* is to support
string, wstring, and dstring with a single overload.
More information about the Digitalmars-d
mailing list