3 ms·
But don't forget that it also doesn't compose as well as the other options.
by valenterry 4y ago
But don't forget that it also doesn't compose as well as the other options.
- WalterBright 4y agoI don't see that as true. I don't recall anyone mentioning that they couldn't compose what they wanted.
- arunc 4y agoI don't think it's true. Show some example? Templates work even in betterC mode.
- valenterry 4y agoCan you template a template?
- ben-schaaf 4y agoI believe so; see the entire meta package in the standard library: https://dlang.org/phobos/std_meta.html https://dlang.org/phobos/std_meta.html
- valenterry 4y agoUsually when something is called "meta" it means that it is special and does not compose. I had someone explaining D templates to me on an Idris meetup, but it's been a few years, so I might very well be wrong here and not remember correctly. I'm happy to be corrected. My next question would be: can I write those meta templates myself and modify them with themselves? In the same way that I could have a type-level function that applies another type-level function twice and then apply it on itself to get a new type-level function that applies another type-level function four times.
- WalterBright 4y agoDo you mean does recursion work? Absolutely!
- valenterry 4y agoI wasn't talking about recursion but composition. Can I write template A and then apply it to itself to get template B and then apply that onto template C to get template D.
- WalterBright 4y agoYes.
- valenterry 4y agoI can't quite wrap my head around how that would work, but I'll trust you and then take my original claim back!
- he_the_great 4y agoauto alist = [1, 3, 2]; alist .sort .map!(x => x * x) .map!(x => x - x/2) .map!(x => x + 1); This seems like what you're asking. Each of those is a template. And while this is all logic code, D has inferred the type aka: SortedRange!Map!Map!Map With some details removed.