what is the NotSure type returned by declare??? if i say Gen(name, T) i receive errors from the compiler which effectively boils down to longer_name being different from name…
in general, is there some equivalent of anytype i could use for my function return types???
That depends on if you can invoke your function at comptime. We do this in Fluent to chain unary calls that could have multiple intermediate type transformations. You can invoke a function and analyze its return directly:
The reason this pattern may help is if you have function signatures like this:
fn bar(x: anytype) @TypeOf(x) ...
As the @typeInfo’s Fn.return_type will be null and it makes them hard to analyze. If you directly invoke it, it can save a lot of time (not applicable in all circumstances though).
it turns out my use-case had an additional layer of complexity, in that the return type from declare itself turns out to conditional on some comptime test…
this actually worked splendly in VSCode – where the result type of declare appeared as an either type… more important, when i typed a “.” in the editor i was presented with a set of all possible pub names i could select (with a nice “comment” that effectively told me under which condition these would actually be available)…
this is incredibly impressive, in that some additional contextual information is available to users operating on the object returned by declare…