digitalmars.dip.ideas - Traits for named varargs
- monkyyy (19/19) May 15 I dont know what progress there been on named arguments, but...
- Nick Treleaven (8/23) May 16 The only way I know is to provide the type sequence for T:
I dont know what progress there been on named arguments, but... it seems like its been a while As a bandaid, just vomit some sort of ugly details at me in a trait ```d import std; void foo(T...)(T args,bool magic=true){ args.writeln; magic.writeln; } unittest{ foo(1,2,3); foo(1,2,magic:false); } ``` I know of no way to make even this simple code work so, `__traits(namesofvarargs,T)==["","","magic"]`; give me one piece of data and I can figure it out and make some better apis until full named tuples come.
May 15
On Thursday, 15 May 2025 at 22:08:45 UTC, monkyyy wrote:```d import std; void foo(T...)(T args,bool magic=true){ args.writeln; magic.writeln; } unittest{ foo(1,2,3); foo(1,2,magic:false); } ``` I know of no way to make even this simple code workThe only way I know is to provide the type sequence for T: ```d alias Seq(S...) = S; foo!(Seq!(int, int))(1, 2, magic:false); ```so, `__traits(namesofvarargs,T)==["","","magic"]`; give me one piece of data and I can figure it out and make some better apis until full named tuples come.T doesn't know anything about `magic`, it's just a type sequence. Also, `args` is not a variadic parameter.
May 16