Parameterized delegate attributes
Lodovico Giaretta via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 28 10:00:49 PDT 2016
On Wednesday, 28 September 2016 at 16:20:18 UTC, Eyal Lotem wrote:
> [...]
I would just make opApply a templated function, for the following
reasons:
1) You are saying that having this feature in the language would
spare some template instantiations and code generations; but a
good compiler should be able to recognize functions with the same
code and fold them; for example, if a function takes a generic
pointer, chances are it doesn't need to be duplicated for every
pointer type.
2) It is actually not true that attributes are only for type
checking; the compiler can use them to generate different code: a
nothrow function does not need machinery to forward exceptions
and clean the stack, for example; so templates are the correct
way here, because they can generate different code when needed
and also be folded to a single codegen if possible.
More information about the Digitalmars-d
mailing list