Compile-time fold expression vs recursive template

Paul Backus snarwin at gmail.com
Sat Jun 13 12:35:58 UTC 2020


On Saturday, 13 June 2020 at 10:52:46 UTC, Nick Treleaven wrote:
> Recently 2 ideas have been proposed to reduce the need for 
> recursive templates:
>
[...]
>
> So I've come up with something that is between the two, but 
> hopefully is still general enough to implement a fairly wide 
> class of recursive templates. The idea is to have an expression 
> which recursively evaluates arguments for the next iteration, 
> similar to std.algorithm.fold but at compile-time.
> https://dlang.org/phobos/std_algorithm_iteration.html#fold
>
[...]
>
> What do you think?

This is fundamentally the same kind of thing as the proposed 
`...` operator--a single AST macro added to the language as a 
special-case feature, rather than a general facility for doing 
AST-macro-like things.

Of course, Walter has vetoed full-fledged AST macros, so we won't 
be seeing those in D any time soon, but I think it is perhaps 
worth taking a look at which features of AST macros would be 
useful to have (e.g., not storing intermediate values in the 
symbol table), and attempting to design a general-purpose 
facilities that give the programmer access to those features.


More information about the Digitalmars-d mailing list