January 14, 2012Re: A tutorial on D templates
On Sat, Jan 14, 2012, at 09:07 AM, Philippe Sigaud wrote: > >> On 13/01/12 10:48 PM, DNewbie wrote: > >> > I can't understand it. Why would someone need template programming. What problem does template solve? > > Well read on and see :-) > > Peter: > >> Suppose you want to write a function to get the minimum of two integers. > >> It's easy: > > > > Oh.. I see. > > Thank you everybody. > > And that's the first, more visible part of templates, a bit like > generics in Java. > Template are incomplete pieces of code with left-empty 'slots' which > you can fill at compile-time to decide what code will be compiled. > You can generate entire functions / class hierarchies or nicely > crafted-for-your-need code / pre-computed-by-the-compiler code with > templates. > > Philippe > OK... I won't play with templates for now, but please keep up the good work.