Yet another terrible compile time argument proposal
Steven Schveighoffer
schveiguy at gmail.com
Sun Jan 14 22:09:15 UTC 2024
On Sunday, 14 January 2024 at 22:02:21 UTC, Nickolay Bukreyev
wrote:
> I think I have a challenge. Can you write a function that
> accepts an arbitrary number of key-value pairs? All keys should
> be compile-time strings; all values should be runtime ints;
> keys and values should alternate.
>
> ```d
> int value1, value2;
> foo("key1", value1, "key2", value2);
> ```
Not with that calling syntax. You'd have to do it via a key array
(compile time) and a value array (runtime, maybe variadic).
Some of the SI proposals essentially do just this -- transform
the argument order/structure.
-Steve
More information about the Digitalmars-d
mailing list