Yet another terrible compile time argument proposal
Steven Schveighoffer
schveiguy at gmail.com
Mon Jan 15 16:49:24 UTC 2024
On Sunday, 14 January 2024 at 21:27:44 UTC, Steven Schveighoffer
wrote:
> I'm going to propose something that furthers the baggage of
> `enum`, but that is the tool we currently have... Happy to
> think about better syntax. But why not just:
>
> ```d
> void foo(T)(T x, enum string s)
> {
> pragma(msg, s); // s is compile-time
> }
>
> void main(string[] args)
> {
> foo(1, "hi"); // ok
> foo(1, "hello"); // ok, but a different instantiation
> foo(1, args[1]); // error, second argument must be compile
> time
> }
> ```
Unbeknownst to me, Quirin F. Schroll has already created a
[pretty robust DIP](https://github.com/dlang/DIPs/pull/232) that
is ready for proposing, describing basically exactly what I was
proposing, with all the hairy details worked out.
I apologize for not recognizing this, and hope that this DIP is
considered and accepted!
This indeed would enable a much simpler mechanism for the SI
proposals to be dealt with at compile time.
-Steve
More information about the Digitalmars-d
mailing list