www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Template hell apis are necessy for a functional d3

reply monkyyy <crazymonkyyy gmail.com> writes:
 phobos v3 will have less templates, especially conv.to -dconf
```d struct myint{ int i; bool isvalid; int to!int()=>cast(int)i; } import std.conv; myint[][][string] foo; foo.to!(int[][][string]); ``` A recursive hyper overloaded .to template is the best way to support this operation of nested user types; theres things to be said about simplifying the std, but its not via removing templates as a preemptive style decision. ```d T[] to(T[],S)(S[] array...){ T[] output; foreach(e;array){ output~=e; } return output; } ``` The average block of std code is about 1000x more complex then what I would write but templates are essental complexity here
Sep 17
parent Salih Dincer <salihdb hotmail.com> writes:
On Wednesday, 18 September 2024 at 04:55:53 UTC, monkyyy wrote:
 The average block of std code is about 1000x more complex then 
 what I would write but templates are essental complexity here
I also create my own types in embedded implement the array(), take() and to() methods as you mentioned. I actually like the HOFs, but you need to stay away from situations that require speed. SDB 79
Sep 17