Idea: limited template expansion
David Nadlinger via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jan 21 07:02:45 PST 2016
On Thursday, 21 January 2016 at 13:36:28 UTC, Steven
Schveighoffer wrote:
> On 1/20/16 6:01 PM, David Nadlinger wrote:
>> How would the client code be simpler with a built-in language
>> feature?
>
> The use case I have in mind is a parser, let's say an xml
> parser.
>
> […]
I still don't see how a language feature as described in your
first post would make this any easier than using a template for
that exact purpose (switching between methods to call).
If what you are trying to say is that you want the different
template function instantiations to return incompatible types in
addition to that, the feature from your initial post won't help
you there either. Values can't have different types in
non-template code, so you'd necessarily need to make the client
code a template too. Streamlining the runtime -> compile time
value dispatch process (as shown in your initial example) doesn't
change the fact that the type of a given value cannot be
influenced by runtime decisions.
— David
More information about the Digitalmars-d
mailing list