Inplace lambda execution

monkyyy crazymonkyyy at gmail.com
Fri Mar 28 12:49:44 UTC 2025


On Friday, 28 March 2025 at 12:12:45 UTC, confuzzled wrote:
> I apologize for the newbie question but how do I get the lambda 
> the following to execute and return a string instead of the 
> function pointer?:
>
> private static immutable string[] typeNames = [staticMap!(T => 
> typeof(T).stringof, TypeSeq)];
>
> I currently get this error:
>
> ```D
> sumtype.d(61): Error: cannot implicitly convert expression 
> `(int T) => "int"` of type `string function(int T) pure nothrow 
> @nogc @safe` to `immutable(string)`
>     private static immutable string[] typeNames = [staticMap!(T 
> => typeof(T).stringof, TypeSeq)];
>                                                    ^
> ```
>
> Thanks in advance.
>
> -- confuzzled

static map cant take a lamda; the syntax of templates are all 
uglier

`enum F(T)=T.stringof; enum typeNames = [staticMap!(F, 
TypeSeq)];` or something



More information about the Digitalmars-d-learn mailing list