March 19, 2012
On Mon, Mar 19, 2012 at 20:37, H. S. Teoh <hsteoh@quickfur.ath.cx> wrote:
>
> It would be nice if somebody could write up a general introduction to the idea of templates (not specific to D), the motivations behind it, perhaps some historical background, and then eventually lead up to advanced template tricks using D as the prime example.
>
> Then not only we can point newbies at the document, but it can also serve as D propaganda.
>
> I'd take a stab at this, except that my free time is limited and most of it is currently being used for refining my AA implementation so that it can (hopefully) replace the current AA mess.

As Ali said, there is a chapter of his D book about templates:

http://ddili.org/ders/d.en/templates.html


And I wrote a document on templates (I call it a tutorial):

https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf

I saw someone said it skips too fast to over the easy stuff. Should I say more on the first chapters?
March 19, 2012
"Andrei Alexandrescu" <SeeWebsiteForEmail@erdani.org> wrote in message news:jk81a6$2o7l$1@digitalmars.com...
> On 3/19/12 1:59 PM, Sean Kelly wrote:
>> I see this a lot, and it's why I wrote the chapter on templates for Learn to Tango with D.  I don't think I can sort out releasing the chapter though.  One approach is to think of templates as compile-time polymorphism.  In Java, you might create a linked-list as:
> [snip]
>
> There have been a couple of long good answers in this thread, and it would be a shame to let them scroll by the way newsgroup messages do. I suggest authors to repackage their posts as blog entries or articles.
>

I've been planning to do so with mine, just haven't gotten to it yet...


March 23, 2012
"Nick Sabalausky" <a@a.a> wrote in message news:jk2ro7$6dl$1@digitalmars.com...
>
> Here's a little templates primer, I hope it helps:
>
> [...]

I've cleaned this up, added an intro and outro, and posted it on my website here:

https://www.semitwist.com/articles/article/view/template-primer-in-d


March 23, 2012
On Fri, Mar 23, 2012 at 01:16:13AM -0400, Nick Sabalausky wrote:
> "Nick Sabalausky" <a@a.a> wrote in message news:jk2ro7$6dl$1@digitalmars.com...
> >
> > Here's a little templates primer, I hope it helps:
> >
> > [...]
> 
> I've cleaned this up, added an intro and outro, and posted it on my website here:
> 
> https://www.semitwist.com/articles/article/view/template-primer-in-d
[...]

+1. Good introduction to D templates.

Pity you didn't get into fancy stuff like recursive templates, but I suppose that's out of the scope of an intro. :-)


T

-- 
Those who've learned LaTeX swear by it. Those who are learning LaTeX swear at it. -- Pete Bleackley
March 23, 2012
"H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote in message news:mailman.1037.1332480633.4860.digitalmars-d@puremagic.com...
> On Fri, Mar 23, 2012 at 01:16:13AM -0400, Nick Sabalausky wrote:
>> "Nick Sabalausky" <a@a.a> wrote in message news:jk2ro7$6dl$1@digitalmars.com...
>> >
>> > Here's a little templates primer, I hope it helps:
>> >
>> > [...]
>>
>> I've cleaned this up, added an intro and outro, and posted it on my website here:
>>
>> https://www.semitwist.com/articles/article/view/template-primer-in-d
> [...]
>
> +1. Good introduction to D templates.
>

Thanks :)

> Pity you didn't get into fancy stuff like recursive templates, but I suppose that's out of the scope of an intro. :-)
>

Yea. Just kind of a "So what are these 'template' things anyway?"

And some of that fancier template stuff (like template fibonacci) is better done as CTFE anyway ;)


March 23, 2012
On Mar 22, 2012, at 10:31 PM, H. S. Teoh wrote:

> On Fri, Mar 23, 2012 at 01:16:13AM -0400, Nick Sabalausky wrote:
>> "Nick Sabalausky" <a@a.a> wrote in message news:jk2ro7$6dl$1@digitalmars.com...
>>> 
>>> Here's a little templates primer, I hope it helps:
>>> 
>>> [...]
>> 
>> I've cleaned this up, added an intro and outro, and posted it on my website here:
>> 
>> https://www.semitwist.com/articles/article/view/template-primer-in-d
> [...]
> 
> +1. Good introduction to D templates.
> 
> Pity you didn't get into fancy stuff like recursive templates, but I suppose that's out of the scope of an intro. :-)

The chapter on templates in Learn to Tango with D gets into the basics of template metaprogramming, but in article form it would probably be part 3 of a series.  I think that chapter is ~20 pages long.
March 23, 2012
On Mar 22, 2012, at 10:35 PM, Nick Sabalausky wrote:
> 
> And some of that fancier template stuff (like template fibonacci) is better done as CTFE anyway ;)

It is, but I think it should be covered anyway because people may still encounter this code and should be able to grasp what it's doing.
1 2 3 4 5 6
Next ›   Last »