Is there a nice syntax to achieve optional named parameters?
Matheus
stop at spam.com
Thu Jan 17 12:11:02 UTC 2019
On Thursday, 17 January 2019 at 01:43:42 UTC, SrMordred wrote:
> Let me throw this idea here:
>...
I usually do this too, I like to use struct and then in another
language I use reflection do optimize binding.
Anyway I understood all your code, except for this "alias code"
> auto NewWindow( alias code )()
> {
> mixin("Config config = {"~code~"};");
> return Window(config);
> }
Looking on specs: https://dlang.org/spec/declaration.html#alias
"AliasDeclarations create a symbol that is an alias for another
type, and can be used anywhere that other type may appear."
So with your example imagine this:
foo(alias x){}
foo("a");
foo(1);
'x' will be string one time and integer another? Or there is
something that I'm missing.
Matheus.
More information about the Digitalmars-d-learn
mailing list