Templates - What's Up with the template keyword?

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Apr 9 21:02:30 UTC 2019


On Tue, Apr 09, 2019 at 04:48:45PM -0400, Steven Schveighoffer via Digitalmars-d-learn wrote:
> On 4/9/19 4:31 PM, Ron Tarrant wrote:
> 
> > I'm still struggling to understand templates, but I'll keep at it.
[...]
> The thing that made it click for me is that a template is very akin to
> a macro substitution -- where you just copy and paste the given
> parameter wherever its substitute is found.
[...]

Yes, templates are, functionally speaking, macros with type safety, and
in D's case syntactic sanity, and none of the disadvantages of an actual
macro system.


T

-- 
Heads I win, tails you lose.


More information about the Digitalmars-d-learn mailing list