www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - A tutorial on D templates

reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
[Cross-posted with D.learn, since it's also a learning-related post]

Hello all,

I discovered D a few years ago and, seeing the recent increase in community
projects, I looked for a way to bring my own small part to it.

I quite like D templates and wanted to try LaTeX again, so I decided to bite the
bullet and wrote a tutorial on templates. It's far from finished and most
probably
full of mistakes but since it's already quite big, I need some inputs.

It's a Github project, here:

https://github.com/PhilippeSigaud/D-templates-tutorial

The resulting pdf is there:

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

(click on View Raw)

If you have any comment, criticism, explanation, what have you, I'm game. What
section should be expanded, what example would be cool, etc. If you see a
mistake,
do not hesitate to tell me: it's the first time I put thoughts on paper like
this.
Github issues management is far from perfect, but it's usable. Even better would
be pull requests :)

There is an 'Examples' section where I show what can be done with templates and
there I 'borrowed' some code posted here, with attribution. I already exchanged
with Andrej Mitrovic (thanks!), but also took some code from Timon Gehr, Simen
Kjaeraas, Trass3r and Jacob Carlborg. Guys, if any of you have a problem with
that, tell me so and I'll take down the code of course. But if any of you could
give me some explanation (a small paragraph or two?) about what your code does,
I'll be forever grateful :)

This also extend to anyone who would want to share some template love/lore with
the rest of us.

Philippe
Jan 13 2012
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Philippe Sigaud:

 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf
 
 (click on View Raw)
I am using a pdf blocking plug-in, that causes that GitHub link to save a fake pdf file :-( Is your tutorial containing the (a,b) => a * b syntax too? I'd like operators in your text to have a space around: a * b instead of a*b (Unless the space is finishing on the line). In my opinion foo!q{ a * b } Is more readable than: foo!"a*b" Bye, bearophile
Jan 13 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Fri, Jan 13, 2012 at 23:07, bearophile <bearophileHUGS lycos.com> wrote:
 Philippe Sigaud:

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

 (click on View Raw)
I am using a pdf blocking plug-in, that causes that GitHub link to save a fake pdf file :-(
On the main project page, there is a Zip icon on the left, to download the entire project as a zip, pdf included. Of course, if you've git installed: $ git clone git github.com:PhilippeSigaud/D-Template-Tutorial.git should do the trick.
 Is your tutorial containing the (a,b) => a * b syntax too?
A bit. I began in september and had to change bits due to D evolutions:) (CTFE opening new possibilities and this new syntax). But I still have many things to change, and I didn't explain this syntax. If you want to discuss the text, I propose we do it on D.learn, so as not to pollute D.announce too much. Philippe
Jan 14 2012
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/13/2012 1:20 PM, Philippe Sigaud wrote:
 This also extend to anyone who would want to share some template love/lore with
 the rest of us.
I see you've already done a great deal of work on this, it looks nice! I strongly encourage you to continue with it, and release it as a book. We could sure use another book on D! I strongly suggest making the formatting work for a Kindle edition of your book. PDF files do badly on e-readers. Minor stylistic nit pet peeve of mine: please remove the word "you" and "your" from the prose. It's nearly always redundant, and the sentences flow better without it. "You" is a filler word, similar to "um", "like", and "basically". For example, Like, I basically think that you will basically prefer the, um, text once basically you, like, remove basically them, like, ok. Know what I'm saying? => The text will look better without them. :-)
Jan 14 2012
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, January 14, 2012 00:16:37 Walter Bright wrote:
 On 1/13/2012 1:20 PM, Philippe Sigaud wrote:
 This also extend to anyone who would want to share some template
 love/lore with the rest of us.
I see you've already done a great deal of work on this, it looks nice! I strongly encourage you to continue with it, and release it as a book. We could sure use another book on D! I strongly suggest making the formatting work for a Kindle edition of your book. PDF files do badly on e-readers. Minor stylistic nit pet peeve of mine: please remove the word "you" and "your" from the prose. It's nearly always redundant, and the sentences flow better without it. "You" is a filler word, similar to "um", "like", and "basically". For example, Like, I basically think that you will basically prefer the, um, text once basically you, like, remove basically them, like, ok. Know what I'm saying? => The text will look better without them. :-)
I confess that it's a bit of a pet peeve of mine when people insist on avoiding words like you and your. I completely disagree that it's a problem. And there are times where avoiding it can cause problems and make the text more awkward (though it is true that you can often avoid it fairly easily if you really want to). But I know that there are plenty of technical writers who would agree with you. - Jonathan M Davis
Jan 14 2012
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 12:36 AM, Jonathan M Davis wrote:
 I confess that it's a bit of a pet peeve of mine when people insist on
 avoiding words like you and your. I completely disagree that it's a problem.
 And there are times where avoiding it can cause problems and make the text
 more awkward (though it is true that you can often avoid it fairly easily if
 you really want to).
(though it is true that it can be avoided fairly easily) Fixed that for you. What advantage does the "you" version have, besides upping the word count?
 But I know that there are plenty of technical writers who would agree with
 you.
I cannot recall any professional technical book that used "you" (yes, I'm sure you can find an example!). It's like wearing jeans to a wedding.
Jan 14 2012
next sibling parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, January 14, 2012 10:26:22 Walter Bright wrote:
 On 1/14/2012 12:36 AM, Jonathan M Davis wrote:
 I confess that it's a bit of a pet peeve of mine when people insist on
 avoiding words like you and your. I completely disagree that it's a
 problem. And there are times where avoiding it can cause problems and
 make the text more awkward (though it is true that you can often avoid
 it fairly easily if you really want to).
(though it is true that it can be avoided fairly easily) Fixed that for you. What advantage does the "you" version have, besides upping the word count?
There are certainly times when reducing how much "you" is used reduces the amount of text at no extra cost, but there are other times, when it's far more natural to use "you," and it can become harder to produce sentences without completely reworking that section of text if "you" is removed. And honestly, it just seems overly picky to me. Sure, it can reduce the word count, but I really don't think that it does all that much to improve the quality of the text, and it can require quite a bit more work, since it tends to be unnatural to avoid "you" in the way that technical writers like to. - Jonathan M Davis
Jan 14 2012
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 11:00 AM, Jonathan M Davis wrote:
 There are certainly times when reducing how much "you" is used reduces the
 amount of text at no extra cost, but there are other times, when it's far more
 natural to use "you," and it can become harder to produce sentences without
 completely reworking that section of text if "you" is removed. And honestly,
 it just seems overly picky to me. Sure, it can reduce the word count, but I
 really don't think that it does all that much to improve the quality of the
 text, and it can require quite a bit more work, since it tends to be unnatural
 to avoid "you" in the way that technical writers like to.
You and I are going to disagree on this. But I will add that excessive use of "you" in technically minded books tends to, in my mind, reduce the book a grade in quality. This is not a decision I consciously make, it's just that it doesn't read like a professional technical book would. In fact, it took me a while to figure out why I didn't find certain texts to be professional sounding. Like I said, it's like wearing jeans to a wedding. It doesn't matter how nice the jeans are, or that jeans are appropriate in other contexts. It doesn't matter how you feel about it. Strunk & White's "The Elements of Style" rule 17: Omit Needless Words
 and it can require quite a bit more work,
This is not an issue. The whole of the document can be fixed in a handful of minutes.
Jan 14 2012
next sibling parent Jonathan M Davis <jmdavisProg gmx.com> writes:
On Saturday, January 14, 2012 11:30:25 Walter Bright wrote:
 You and I are going to disagree on this.
I didn't really expect otherwise. - Jonathan M Davis
Jan 14 2012
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound2 digitalmars.com> wrote in message 
news:jesl4i$30v3$1 digitalmars.com...
 You and I are going to disagree on this.
Dosn't the reader mean "The reader and I are going to disagree on this"? ;) (only j/k, of course. Although I have always hated when authors say "the reader" instead of "you" which is what was obviously meant anyway. I just sounds bad. I always read it as a clear sign the author was trying *way* too hard to be "correct".)
 But I will add that excessive use of "you" in technically minded books 
 tends to, in my mind, reduce the book a grade in quality.
The key there is "excessive use", not "any use". Eliminating excessive use of "you" certainly improves the quality. But compulsively eliminating "you", at best, makes the text sound pedantic, at worst, decreases the quality. Either way, compulsively eliminating it leads to pointless contrivances and awkward euphemisms like "the reader". (Much like my use of "like" in the previous sentence. Yes, "like" can be filler, but changing that sentence to use "such as" would have done nothing but...pointlessly increase the word count.)
Jan 14 2012
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 1:00 PM, Nick Sabalausky wrote:
 "Walter Bright"<newshound2 digitalmars.com>  wrote in message
 news:jesl4i$30v3$1 digitalmars.com...
 You and I are going to disagree on this.
Dosn't the reader mean "The reader and I are going to disagree on this"? ;) (only j/k, of course. Although I have always hated when authors say "the reader" instead of "you" which is what was obviously meant anyway. I just sounds bad. I always read it as a clear sign the author was trying *way* too hard to be "correct".)
I agree with your comment about "the reader" being pretentious. As for my use of "you" there, I was talking specifically to Jonathan. That's different from writing a tech manual. Wearing jeans is appropriate in a conversation.
 But I will add that excessive use of "you" in technically minded books
 tends to, in my mind, reduce the book a grade in quality.
The key there is "excessive use", not "any use". Eliminating excessive use of "you" certainly improves the quality. But compulsively eliminating "you", at best, makes the text sound pedantic, at worst, decreases the quality. Either way, compulsively eliminating it leads to pointless contrivances and awkward euphemisms like "the reader".
The steps are: Novice: follow the rules because you're told to Master: follow the rules because you understand the rules Guru: break the rules because you know the limits of the rules
Jan 14 2012
parent "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound2 digitalmars.com> wrote in message 
news:jet0kk$1h97$1 digitalmars.com...
 On 1/14/2012 1:00 PM, Nick Sabalausky wrote:
 "Walter Bright"<newshound2 digitalmars.com>  wrote in message
 news:jesl4i$30v3$1 digitalmars.com...
 You and I are going to disagree on this.
Dosn't the reader mean "The reader and I are going to disagree on this"? ;) (only j/k, of course. Although I have always hated when authors say "the reader" instead of "you" which is what was obviously meant anyway. I just sounds bad. I always read it as a clear sign the author was trying *way* too hard to be "correct".)
I agree with your comment about "the reader" being pretentious. As for my use of "you" there, I was talking specifically to Jonathan. That's different from writing a tech manual. Wearing jeans is appropriate in a conversation.
Yup, just kidding on that like I said. :)
 But I will add that excessive use of "you" in technically minded books
 tends to, in my mind, reduce the book a grade in quality.
The key there is "excessive use", not "any use". Eliminating excessive use of "you" certainly improves the quality. But compulsively eliminating "you", at best, makes the text sound pedantic, at worst, decreases the quality. Either way, compulsively eliminating it leads to pointless contrivances and awkward euphemisms like "the reader".
The steps are: Novice: follow the rules because you're told to Master: follow the rules because you understand the rules Guru: break the rules because you know the limits of the rules
Very, very true.
Jan 16 2012
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
Since we're on this topic I can't stop picking - all in good fun I hope 
- on Jonathan, the master of words. The following two sentences convey 
the same exact information:

1.

 There are certainly times when reducing how much "you" is used reduces the
 amount of text at no extra cost, but there are other times, when it's far more
 natural to use "you," and it can become harder to produce sentences without
 completely reworking that section of text if "you" is removed.
2.
 Sure, it can reduce the word count, but I
 really don't think that it does all that much to improve the quality of the
 text, and it can require quite a bit more work, since it tends to be unnatural
 to avoid "you" in the way that technical writers like to.
This pattern is quite frequent in Jonathan's posts. I trained myself to skip the last sentence of each paragraph and often the last paragraph entirely. Andrei
Jan 14 2012
next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 21:14, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:

 This pattern is quite frequent in Jonathan's posts. I trained myself to skip
 the last sentence of each paragraph and often the last paragraph entirely.
:) I do the same.
Jan 14 2012
prev sibling next sibling parent reply Timon Gehr <timon.gehr gmx.ch> writes:
On 01/14/2012 09:14 PM, Andrei Alexandrescu wrote:
 Since we're on this topic I can't stop picking - all in good fun I hope
 - on Jonathan, the master of words. The following two sentences convey
 the same exact information:

 1.

 There are certainly times when reducing how much "you" is used reduces
 the
 amount of text at no extra cost, but there are other times, when it's
 far more
 natural to use "you," and it can become harder to produce sentences
 without
 completely reworking that section of text if "you" is removed.
2.
 Sure, it can reduce the word count, but I
 really don't think that it does all that much to improve the quality
 of the
 text, and it can require quite a bit more work, since it tends to be
 unnatural
 to avoid "you" in the way that technical writers like to.
This pattern is quite frequent in Jonathan's posts. I trained myself to skip the last sentence of each paragraph and often the last paragraph entirely. Andrei
In longer posts, I think the information is often laid out in an approximately palindromic way.
Jan 14 2012
parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 1:09 PM, Timon Gehr wrote:
 In longer posts, I think the information is often laid out in an approximately
 palindromic way.
We're not in Notlob, you know.
Jan 14 2012
prev sibling parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/14/2012 12:14 PM, Andrei Alexandrescu wrote:
 Since we're on this topic I can't stop picking - all in good fun I hope
 - on Jonathan, the master of words. The following two sentences convey
 the same exact information:

 1.

 There are certainly times when reducing how much "you" is used reduces
 the
 amount of text at no extra cost, but there are other times, when it's
 far more
 natural to use "you," and it can become harder to produce sentences
 without
 completely reworking that section of text if "you" is removed.
2.
 Sure, it can reduce the word count, but I
 really don't think that it does all that much to improve the quality
 of the
 text, and it can require quite a bit more work, since it tends to be
 unnatural
 to avoid "you" in the way that technical writers like to.
This pattern is quite frequent in Jonathan's posts. I trained myself to skip the last sentence of each paragraph and often the last paragraph entirely. Andrei
I've always wanted to say the same but I couldn't be sure that I wouldn't be offensive. Now, hiding behind Andrei: +1 :) Ali
Jan 14 2012
prev sibling next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 12:26 PM, Walter Bright wrote:
 On 1/14/2012 12:36 AM, Jonathan M Davis wrote:
 I confess that it's a bit of a pet peeve of mine when people insist on
 avoiding words like you and your. I completely disagree that it's a
 problem.
 And there are times where avoiding it can cause problems and make the
 text
 more awkward (though it is true that you can often avoid it fairly
 easily if
 you really want to).
(though it is true that it can be avoided fairly easily) Fixed that for you. What advantage does the "you" version have, besides upping the word count?
 But I know that there are plenty of technical writers who would agree
 with
 you.
I cannot recall any professional technical book that used "you" (yes, I'm sure you can find an example!). It's like wearing jeans to a wedding.
"You" can convey a conversational, intimate tone that can be helpful. Together with "I" for the author and "we" as the author plus the reader, "you" can create quite a good frame. That being said, I agree - "you" is a license that should be at best used sparingly, as is "I". Andrei
Jan 14 2012
prev sibling parent deadalnix <deadalnix gmail.com> writes:
Le 14/01/2012 19:26, Walter Bright a écrit :
 On 1/14/2012 12:36 AM, Jonathan M Davis wrote:
 I confess that it's a bit of a pet peeve of mine when people insist on
 avoiding words like you and your. I completely disagree that it's a
 problem.
 And there are times where avoiding it can cause problems and make the
 text
 more awkward (though it is true that you can often avoid it fairly
 easily if
 you really want to).
(though it is true that it can be avoided fairly easily) Fixed that for you. What advantage does the "you" version have, besides upping the word count?
 But I know that there are plenty of technical writers who would agree
 with
 you.
I cannot recall any professional technical book that used "you" (yes, I'm sure you can find an example!). It's like wearing jeans to a wedding.
« The linker will fluently and baroquely remind you of that in its native language, encrypted klingon » Copied verbatim from a certain book I'm sure you know about ;) But I have too agrre, some you is good, too much of it isn't in a technical paper.
Feb 08 2012
prev sibling next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 09:16, Walter Bright <newshound2 digitalmars.com> wrote:
 On 1/13/2012 1:20 PM, Philippe Sigaud wrote:
 This also extend to anyone who would want to share some template love/lore
 with
 the rest of us.
I see you've already done a great deal of work on this, it looks nice!
Thanks. LaTeX work, mostly. At one time, I asked Andrei for the latex formatting functions used in TDPL, but he was authorized to distribute it. That would permit D docs to get TDPL look & feel.
 I strongly encourage you to continue with it, and release it as a book. We
 could sure use another book on D!
Uh, I don't think it'll ever be a book. I didn't write it with a book in mind.
 I strongly suggest making the formatting work for a Kindle edition of your
 book. PDF files do badly on e-readers.
What I want (maybe in 1-2 months) is to write a simple D script that takes the .tex files and transform them into simple marked-up text, to produce a DDoc file or an HTML one. Is there any tex -> <whatever format ebooks use> or pdf -> ebook converters?
 Minor stylistic nit pet peeve of mine: please remove the word "you" and
 "your" from the prose. It's nearly always redundant, and the sentences flow
 better without it. "You" is a filler word, similar to "um", "like", and
 "basically".
I'll look and try. Philippe
Jan 14 2012
next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 3:21 AM, Philippe Sigaud wrote:
 I strongly encourage you to continue with it, and release it as a book. We
 could sure use another book on D!
Uh, I don't think it'll ever be a book. I didn't write it with a book in mind.
It looks like a book, and I see no reason why it can't be. It'll see far wider distribution as a book.
 I strongly suggest making the formatting work for a Kindle edition of your
 book. PDF files do badly on e-readers.
What I want (maybe in 1-2 months) is to write a simple D script that takes the .tex files and transform them into simple marked-up text, to produce a DDoc file or an HTML one.
Kindle ebooks can be automatically generated from HTML text with the kindlegen.exe program downloadable from Amazon. I have the D specification automatically "kindle-izable" in the makefile for dlang.org. The main issue is the short line length, which negatively impacts examples and tables. Another issue is Kindle is black & white, so while the colored text does make it better, it should still be usable if rendered in black & white (which should be done anyway, as many people are color blind).
Jan 14 2012
parent deadalnix <deadalnix gmail.com> writes:
Le 14/01/2012 19:36, Walter Bright a écrit :
 Another issue is Kindle is black & white, so while the colored text does
 make it better, it should still be usable if rendered in black & white
 (which should be done anyway, as many people are color blind).
A good practice is to back up coloring with some other tools to convey information, like different font. Conveying information solely by color is a bad practice. You noticed that it doesn't convert well to black and white, you'll also notice that you'll exclude, de facto, color blind people, who are actually frequent (more than most people think).
Feb 08 2012
prev sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book. Andrei
Jan 14 2012
parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 21:07, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in
 mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book.
Fair point :) In my mind, a book is at least 300 pages and, well, professionally done. I can see Walter's point about ebook though. Thank you all for the encouragements!
Jan 14 2012
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Philippe Sigaud" <philippe.sigaud gmail.com> wrote in message 
news:mailman.374.1326575051.16222.digitalmars-d-announce puremagic.com...
 On Sat, Jan 14, 2012 at 21:07, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in
 mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book.
Fair point :) In my mind, a book is at least 300 pages and, well, professionally done. I can see Walter's point about ebook though.
I have plenty of physical books that are shorter than that!
Jan 14 2012
prev sibling next sibling parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 3:04 PM, Philippe Sigaud wrote:
 On Sat, Jan 14, 2012 at 21:07, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in
 mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book.
Fair point :) In my mind, a book is at least 300 pages and, well, professionally done. I can see Walter's point about ebook though. Thank you all for the encouragements!
Great. With the publishing world undergoing quite some stir, I think it would be very interesting to experience with self-publishing via Kindle. FWIW about 300 - not at all. "Exceptional C++" has 206 pages head to toe and is a great book. In fact 300 is probably a good upper limit in today's short-attention-span world. Andrei
Jan 14 2012
prev sibling next sibling parent Georg Wrede <Georg.Wrede iki.fi> writes:
On 01/14/2012 11:04 PM, Philippe Sigaud wrote:
 On Sat, Jan 14, 2012 at 21:07, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in
 mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book.
Fair point :) In my mind, a book is at least 300 pages and, well, professionally done. I can see Walter's point about ebook though.
Maybe you should check out the original K&R C book. (The pre-ANSI, original edition.) It is arguably the most referenced single book in the history of programming languages, and from its reputation (at least I) assumed it to be more than 1000 pages. It is 176 pages, excluding the appendix. And it reads like something the guys wrote for their colleagues, not for a Book Publisher. From my own writing, I know that the mere thought of writing a book adds an unnecessary burden. So don't. :-)
Jan 14 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-01-14 22:04, Philippe Sigaud wrote:
 On Sat, Jan 14, 2012 at 21:07, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 1/14/12 5:21 AM, Philippe Sigaud wrote:
 Uh, I don't think it'll ever be a book. I didn't write it with a book in
 mind.
It's organized as a book (TOC, index, structure) and has 141 pages with quite a few more to come. At this point it would be more difficult to make it /not/ a book.
Fair point :) In my mind, a book is at least 300 pages and, well, professionally done. I can see Walter's point about ebook though. Thank you all for the encouragements!
Templates is just one part of the language. There are many other parts to write about :) -- /Jacob Carlborg
Jan 15 2012
parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sun, Jan 15, 2012 at 12:16, Jacob Carlborg <doob me.com> wrote:
 Thank you all for the encouragements!
Templates is just one part of the language. There are many other parts to write about :)
*snort* I do think a big range tutorial is overdue. Andrei's article is good, but we need something a bit more detailed / for newbies and shown in the website. Maybe even a .ddoc file with phobos. I wonder if we could provide some Ddoc files like this...
Jan 15 2012
next sibling parent reply =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/15/2012 05:34 AM, Philippe Sigaud wrote:
 On Sun, Jan 15, 2012 at 12:16, Jacob Carlborg<doob me.com>  wrote:
 Thank you all for the encouragements!
Templates is just one part of the language. There are many other parts to write about :)
*snort* I do think a big range tutorial is overdue. Andrei's article is good, but we need something a bit more detailed / for newbies
I am hoping that this is good enough for now: http://ddili.org/ders/d.en/ranges.html
 and shown in
 the website. Maybe even a .ddoc file with phobos.

 I wonder if we could provide some Ddoc files like this...
Ali
Jan 15 2012
next sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/15/2012 8:00 AM, Ali Çehreli wrote:
 I am hoping that this is good enough for now:

 http://ddili.org/ders/d.en/ranges.html
Very nice, I'll read it more carefully later.
Jan 15 2012
prev sibling next sibling parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/15/2012 8:00 AM, Ali Çehreli wrote:
 I am hoping that this is good enough for now:

 http://ddili.org/ders/d.en/ranges.html
Please, can you turn this into a Kindle ebook? Both the Turkish and English versions? http://ddili.org/ders/d.en/index.html
Jan 15 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/15/2012 12:18 PM, Walter Bright wrote:
 On 1/15/2012 8:00 AM, Ali Çehreli wrote:
 I am hoping that this is good enough for now:

 http://ddili.org/ders/d.en/ranges.html
Please, can you turn this into a Kindle ebook? Both the Turkish and English versions? http://ddili.org/ders/d.en/index.html
Thank you. Will do! :) Ali
Jan 15 2012
prev sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sun, Jan 15, 2012 at 17:00, Ali =C3=87ehreli <acehreli yahoo.com> wrote:

 I do think a big range tutorial is overdue. Andrei's article is good,
 but we need something a bit more detailed / for newbies
I am hoping that this is good enough for now: =C2=A0http://ddili.org/ders/d.en/ranges.html
It sure is! This should be advertised somehow. Maybe add a link in the D Wi= ki? http://prowiki.org/wiki4d/wiki.cgi?D__Tutorial I think many chapters of your book could be linked in there. by the by, I added a Resources appendix, where I cite your chapter on templ= ates. Philippe
Jan 15 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/15/12 4:19 PM, Philippe Sigaud wrote:
 On Sun, Jan 15, 2012 at 17:00, Ali Çehreli<acehreli yahoo.com>  wrote:

 I do think a big range tutorial is overdue. Andrei's article is good,
 but we need something a bit more detailed / for newbies
I am hoping that this is good enough for now: http://ddili.org/ders/d.en/ranges.html
It sure is! This should be advertised somehow.
Should I redditize? Andrei
Jan 15 2012
parent =?UTF-8?B?QWxpIMOHZWhyZWxp?= <acehreli yahoo.com> writes:
On 01/15/2012 04:34 PM, Andrei Alexandrescu wrote:
 On 1/15/12 4:19 PM, Philippe Sigaud wrote:
 On Sun, Jan 15, 2012 at 17:00, Ali Çehreli<acehreli yahoo.com> wrote:

 I do think a big range tutorial is overdue. Andrei's article is good,
 but we need something a bit more detailed / for newbies
I am hoping that this is good enough for now: http://ddili.org/ders/d.en/ranges.html
It sure is! This should be advertised somehow.
Should I redditize? Andrei
If that question was for me, of course I wouldn't mind, at all. ;) Ali
Jan 16 2012
prev sibling parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/15/2012 5:34 AM, Philippe Sigaud wrote:
 I do think a big range tutorial is overdue. Andrei's article is good,
 but we need something a bit more detailed / for newbies and shown in
 the website. Maybe even a .ddoc file with phobos.
Yeah, we badly need a "The Range Manifesto".
Jan 15 2012
prev sibling parent reply Jeff Nowakowski <jeff dilacero.org> writes:
On 01/14/2012 03:16 AM, Walter Bright wrote:
 Minor stylistic nit pet peeve of mine: please remove the word "you" and
 "your" from the prose.
That sounds a bit strict, and looking at one of your articles I see it used in the second sentence: "A pure function does what you'd expect — the compiler enforces purity of the function."
Jan 14 2012
parent reply Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 7:05 AM, Jeff Nowakowski wrote:
 On 01/14/2012 03:16 AM, Walter Bright wrote:
 Minor stylistic nit pet peeve of mine: please remove the word "you" and
 "your" from the prose.
That sounds a bit strict, and looking at one of your articles I see it used in the second sentence: "A pure function does what you'd expect — the compiler enforces purity of the function."
What can I say? Ya got me there. I do tend to write "you", and remove them in a later pass. But let's take some examples from the first page of the text, and see if the elidition looks better: --------------------- giving you powerful compile-time code generation abilities that’ll make your code cleaner, more flexible and even more ecient. => giving powerful compile-time code generation abilities that’ll make code cleaner, more flexible and even more ecient. ------------------------ its material doesn’t so much teach you how to use templates as show you their syntax and semantics. => its material doesn’t so much teach how to use templates as show their syntax and semantics. ----------------------- the standard ‘building blocks’ you'll use in almost all your templates, => the standard ‘building blocks’ used in almost all templates, ----------------------- and what you can build with them in conjunction with templates. => and what can be built with them in conjunction with templates.
Jan 14 2012
next sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Counter-argument: You can't make a pull request to a book. Just take a
look at the mountain of errata entries for tdpl.
Jan 14 2012
parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/14/2012 11:03 AM, Andrej Mitrovic wrote:
 Counter-argument: You can't make a pull request to a book. Just take a
 look at the mountain of errata entries for tdpl.
Ebooks can be fixed easily. Print books cannot.
Jan 14 2012
prev sibling next sibling parent "Nick Sabalausky" <a a.a> writes:
"Walter Bright" <newshound2 digitalmars.com> wrote in message 
news:jesifv$2sm9$1 digitalmars.com...
 ---------------------
 giving you powerful compile-time code generation abilities that'll make 
 your code cleaner, more flexible and even more ecient.

 =>

 giving powerful compile-time code generation abilities that'll make code 
 cleaner, more flexible and even more ecient.
 ------------------------
This particular one, I honestly think the "before" sounds better. But I do agree with...the poster to whom this author is replying to...on the other examples.
Jan 14 2012
prev sibling parent reply Georg Wrede <Georg.Wrede iki.fi> writes:
On 01/14/2012 08:45 PM, Walter Bright wrote:
 On 1/14/2012 7:05 AM, Jeff Nowakowski wrote:
 On 01/14/2012 03:16 AM, Walter Bright wrote:
 Minor stylistic nit pet peeve of mine: please remove the word "you" and
 "your" from the prose.
That sounds a bit strict, and looking at one of your articles I see it used in the second sentence: "A pure function does what you'd expect — the compiler enforces purity of the function."
What can I say? Ya got me there. I do tend to write "you", and remove them in a later pass. But let's take some examples from the first page of the text, and see if the elidition looks better:
Why don't we just let the guy write his thing in peace, before demanding a complete book with stylistically professional grammar and style? I mean, at this rate we are beating the horse to death before we've even put it in front of the carriage. If I were Philippe, by this time I'd be stressed out, and the project would start to whither. How about folks just helping him write it, like he asked? There's plenty of time to turn it to the Ten Commandments later, but it needs to exist before that.
Jan 14 2012
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 6:54 PM, Georg Wrede wrote:
 On 01/14/2012 08:45 PM, Walter Bright wrote:
 On 1/14/2012 7:05 AM, Jeff Nowakowski wrote:
 On 01/14/2012 03:16 AM, Walter Bright wrote:
 Minor stylistic nit pet peeve of mine: please remove the word "you" and
 "your" from the prose.
That sounds a bit strict, and looking at one of your articles I see it used in the second sentence: "A pure function does what you'd expect — the compiler enforces purity of the function."
What can I say? Ya got me there. I do tend to write "you", and remove them in a later pass. But let's take some examples from the first page of the text, and see if the elidition looks better:
Why don't we just let the guy write his thing in peace, before demanding a complete book with stylistically professional grammar and style? I mean, at this rate we are beating the horse to death before we've even put it in front of the carriage. If I were Philippe, by this time I'd be stressed out, and the project would start to whither. How about folks just helping him write it, like he asked? There's plenty of time to turn it to the Ten Commandments later, but it needs to exist before that.
He asked for feedback. People sent feedback. Andrei
Jan 14 2012
parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sun, Jan 15, 2012 at 03:27, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/14/12 6:54 PM, Georg Wrede wrote:
 Why don't we just let the guy write his thing in peace, before demanding
 a complete book with stylistically professional grammar and style?

 I mean, at this rate we are beating the horse to death before we've even
 put it in front of the carriage. If I were Philippe, by this time I'd be
 stressed out, and the project would start to whither.

 How about folks just helping him write it, like he asked?

 There's plenty of time to turn it to the Ten Commandments later, but it
 needs to exist before that.
He asked for feedback. People sent feedback.
No problemo, Georg. I'm not stressed at all by the grammar / style remarks :) I know that my not being a native English speaker will have me write awkward sentences. I'm glad people are sending me corrections: like Andrei said, I asked for feedback. In fact, I'm thrilled to receive remarks, it means people are interested.
Jan 15 2012
parent Walter Bright <newshound2 digitalmars.com> writes:
On 1/15/2012 5:50 AM, Philippe Sigaud wrote:
 In fact, I'm thrilled to receive
 remarks, it means people are interested.
Nothing worse than silence! Also, I would be doing you a disservice if you ask for feedback, and I don't because I thought it might hurt your feelings.
Jan 15 2012
prev sibling parent "Jesse Phillips" <jessekphillips+D gmail.com> writes:
On Sunday, 15 January 2012 at 00:54:37 UTC, Georg Wrede wrote:
 Why don't we just let the guy write his thing in peace, before 
 demanding a complete book with stylistically professional 
 grammar and style?

 I mean, at this rate we are beating the horse to death before 
 we've even put it in front of the carriage. If I were Philippe, 
 by this time I'd be stressed out, and the project would start 
 to whither.

 How about folks just helping him write it, like he asked?

 There's plenty of time to turn it to the Ten Commandments 
 later, but it needs to exist before that.
Getting feedback on writing style early is a great plus to the author. That way he can incorporate it in future additions and practice it, practice catching it. As for the discussion at hand, I prefer to remove 'you' most of the time. It started with just because I was told to in class, but continues because I've seen what it does to my writing, and I prefer it. But I'm still not perfect with it. Also, yay articles/books on D!
Jan 15 2012
prev sibling next sibling parent reply Zachary Lund <admin computerquip.com> writes:
On page 78 where template mixins are discussed, some of the variable 
names feel rather confusing. I would suggest changing them to be more 
distinct.
Jan 14 2012
next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 14:56, Zachary Lund <admin computerquip.com> wrote:
 On page 78 where template mixins are discussed, some of the variable names
 feel rather confusing. I would suggest changing them to be more distinct.
OK, added as an issue. You mean all the 'name', 'Named', 'named'?
Jan 14 2012
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 14:56, Zachary Lund <admin computerquip.com> wrote:
 On page 78 where template mixins are discussed, some of the variable names
 feel rather confusing. I would suggest changing them to be more distinct.
OK, done. Tell me if it's better?
Jan 14 2012
prev sibling next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/13/12 3:20 PM, Philippe Sigaud wrote:
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf

 (click on View Raw)

 If you have any comment, criticism, explanation, what have you, I'm game.
This is great! Should I post to reddit, or hold off a bit more? The document is informative, well written, and beautifully formatted. I found the introduction a bit difficult to get into, so I'm submitting a few suggestions below. I didn't have time to get through everything, but anyway the quality of the text improves very much once it gets into the material. "They are used everywhere in Phobos, D standard library and any D user should know about them." -> "They are used everywhere in Phobos---D's standard library---and therefore any D user should know about them." "But, based on C++’s templates as they are, they can be a bit daunting at first." -> "But, based on C++’s templates as they are, D templates can be a bit daunting at first." "Well, D’s sane syntax for templates, nifty things like static if, alias or tuples cured me of that impression." -> "Well, D’s sane syntax for templates and nifty features such as static if, alias, or tuples, cured me of that impression." (Generally prefer "such as" to "like".) "I hope this docu- ment will help you also." -> "I hope this docu- ment will help you, too." "Part III presents other metaprogramming tools: string mixins (18), compile- time function evaluation (19) and __traits (20)." -> "Part III presents other metaprogramming tools: string mixins (18), compile- time function evaluation (19), and __traits (20)." (Use the "Oxford comma" throughout.) "template-y" -> "\mbox{template-y}" I think italics for comments look a bit baroque, how about slanted text? "...in the next sections (You’ll see for example..." -> "...in the next sections (you’ll see for example..." "... except inside a (standard) function." -> "except inside a (regular) function." Would be great to adjust the code formatting package to not number examples of 1 line long. "Templates Building Blocks" -> "Template Building Blocks" "Up to now, templates must seem not that interesting to you..." -> "Up to now, templates may not seem all that interesting..." "It’s both an expression and a declaration, so I’ll call it a construct." -> "It’s both a statement and a declaration, so I’ll call it a construct." In fact you can call it a declaration because some declarations may occur wherever a statement is allowed. Andrei
Jan 14 2012
next sibling parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 9:56 AM, Andrei Alexandrescu wrote:
[snip]

Oh, one more thing. It would be great to make the explanatory boxes 
either floats, sidebars, or \mbox{}es so they don't span more than one 
page. Look what happened with "Specializations or static if or Templates 
Constraints?" on page 21.


Andrei
Jan 14 2012
next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 17:00, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/14/12 9:56 AM, Andrei Alexandrescu wrote:
 [snip]

 Oh, one more thing. It would be great to make the explanatory boxes either
 floats, sidebars, or \mbox{}es so they don't span more than one page. Look
 what happened with "Specializations or static if or Templates Constraints?"
 on page 21.
I hesitated on this. OK, I'll try, I made it an issue. Do you think code samples should be floats also, so as not to sit on more than on page?
Jan 14 2012
parent Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 10:57 AM, Philippe Sigaud wrote:
 On Sat, Jan 14, 2012 at 17:00, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 1/14/12 9:56 AM, Andrei Alexandrescu wrote:
 [snip]

 Oh, one more thing. It would be great to make the explanatory boxes either
 floats, sidebars, or \mbox{}es so they don't span more than one page. Look
 what happened with "Specializations or static if or Templates Constraints?"
 on page 21.
I hesitated on this. OK, I'll try, I made it an issue. Do you think code samples should be floats also, so as not to sit on more than on page?
Code samples should be able to span multiple pages. Never heard a complaint about it. In contrast, the explanatory boxes are a sort of a unit. Andrei
Jan 14 2012
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 17:00, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/14/12 9:56 AM, Andrei Alexandrescu wrote:
 [snip]

 Oh, one more thing. It would be great to make the explanatory boxes either
 floats, sidebars, or \mbox{}es so they don't span more than one page. Look
 what happened with "Specializations or static if or Templates Constraints?"
 on page 21.
OK, done. I (re)learnt some things about LaTeX spaces, boxes and lengths in the process *shudder*
Jan 14 2012
prev sibling next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 16:56, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/13/12 3:20 PM, Philippe Sigaud wrote:
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf

 (click on View Raw)

 If you have any comment, criticism, explanation, what have you, I'm game.
This is great! Should I post to reddit, or hold off a bit more?
I'd prefer you to wait a bit, because I think I didn't some code samples and they either do not compile or produce different results. That'd badly reflect on D. Maybe I'll write a small script to extract code samples and compile them. Do you have anything like this for TPDL? I have a problem with implicit main() and/or presenting in one sample code that should be in the global scope and some that must be put into a main. I wondered whether I should present only 'compile-as-shown' examples, which means putting import statements and void main() {/* some code */} everywhere.
 The document is informative, well written, and beautifully formatted. I
 found the introduction a bit difficult to get into, so I'm submitting a few
 suggestions below. I didn't have time to get through everything, but anyway
 the quality of the text improves very much once it gets into the material.
Thanks for the compliments and thanks for the suggestions! Indeed, the introductory text was not my main goal while writing this :) I also discovered something you explained when you were writing TDPL: it's difficult to find interesting examples that don't use soon-to-be-introduced features. (snip corrections). Thanks a lot, I'll make them issues and correct this.
 I think italics for comments look a bit baroque, how about slanted text?
I asked myself the same question. I'll dive into pygment's formatting script.
 Would be great to adjust the code formatting package to not number examples
 of 1 line long.
I tried to get two different D environments, one with numbered lines (only when I want to refer to a line, that's less than 5% of all code samples) and an unnumbered one, but it didn't work. I'll try again. Philippe
Jan 14 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 1/14/12 11:08 AM, Philippe Sigaud wrote:
 On Sat, Jan 14, 2012 at 16:56, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 1/13/12 3:20 PM, Philippe Sigaud wrote:
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf

 (click on View Raw)

 If you have any comment, criticism, explanation, what have you, I'm game.
This is great! Should I post to reddit, or hold off a bit more?
I'd prefer you to wait a bit, because I think I didn't some code samples and they either do not compile or produce different results. That'd badly reflect on D. Maybe I'll write a small script to extract code samples and compile them. Do you have anything like this for TPDL?
Emailed.
 I have a problem with implicit main() and/or presenting in one sample
 code that should be in the global scope and some that must be put into
 a main.
Yah, I defined several LaTeX environments and a little syntax for that. I also arranged to ignore "..." when it appears alone on a line. Overall it was an effort well worth it.
 I wondered whether I should present only 'compile-as-shown' examples,
 which means putting import statements and void main() {/* some code
 */} everywhere.
Define distinct environments for stuff that must be top level vs. stuff that must be wrapped in main or unittest. Andrei
Jan 14 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
 Maybe I'll write a small script to extract code samples and compile
 them. Do you have anything like this for TPDL?
Emailed.
Got it, thanks a lot!
 I have a problem with implicit main() and/or presenting in one sample
 code that should be in the global scope and some that must be put into
 a main.
Yah, I defined several LaTeX environments and a little syntax for that. I also arranged to ignore "..." when it appears alone on a line. Overall it was an effort well worth it.
I'll do the scaffolding.
 I wondered whether I should present only 'compile-as-shown' examples,
 which means putting import statements and void main() {/* some code
 */} everywhere.
Define distinct environments for stuff that must be top level vs. stuff that must be wrapped in main or unittest.
OK.
Jan 14 2012
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sat, Jan 14, 2012 at 16:56, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 1/13/12 3:20 PM, Philippe Sigaud wrote:
 "They are used everywhere in Phobos, D standard library and any D user
 should know about them." -> "They are used everywhere in Phobos---D's
 standard library---and therefore any D user should know about them."
Done.
 "But, based on C++=E2=80=99s templates as they are, they can be a bit dau=
nting at
 first." -> "But, based on C++=E2=80=99s templates as they are, D template=
s can be a
 bit daunting at first."
Done.
 "Well, D=E2=80=99s sane syntax for templates, nifty things like static if=
, alias or
 tuples cured me of that impression." -> "Well, D=E2=80=99s sane syntax fo=
r templates
 and nifty features such as static if, alias, or tuples, cured me of that
 impression." (Generally prefer "such as" to "like".)
Done.
 "I hope this docu- ment will help you also." -> "I hope this docu- ment w=
ill
 help you, too."
Done.
 "Part III presents other metaprogramming tools: string mixins (18), compi=
le-
 time function evaluation (19) and __traits (20)." -> "Part III presents
 other metaprogramming tools: string mixins (18), compile- time function
 evaluation (19), and __traits (20)." (Use the "Oxford comma" throughout.)
Done (well, not the Oxford comma)
 "template-y" -> "\mbox{template-y}"
Done.
 I think italics for comments look a bit baroque, how about slanted text?
pygments/minted do not do slanted. I modifyed my own "borland.py" to get non-slanted comments. Anyone generating the pdf from the .tex files will get another highlighting, though.
 "...in the next sections (You=E2=80=99ll see for example..." -> "...in th=
e next
 sections (you=E2=80=99ll see for example..."
Done.
 "... except inside a (standard) function." -> "except inside a (regular)
 function."
Done.
 Would be great to adjust the code formatting package to not number exampl=
es
 of 1 line long.
Done. Now, only code samples where I refer to some lines are numbered.
 "Templates Building Blocks" -> "Template Building Blocks"
Done.
 "Up to now, templates must seem not that interesting to you..." -> "Up to
 now, templates may not seem all that interesting..."
Done.
 "It=E2=80=99s both an expression and a declaration, so I=E2=80=99ll call =
it a construct." ->
 "It=E2=80=99s both a statement and a declaration, so I=E2=80=99ll call it=
a construct." In
 fact you can call it a declaration because some declarations may occur
 wherever a statement is allowed.
Done. Thanks for the comments!
Jan 14 2012
prev sibling next sibling parent reply dennis luehring <dl.soluz gmx.net> writes:
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf
can't open the pdf with acrobat reader under win7 :( (the file seems to be ok, contains the pdf header) im using the latest acrobat reader x
Jan 15 2012
next sibling parent d coder <dlang.coder gmail.com> writes:
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf
can't open the pdf with acrobat reader under win7 :( (the file seems to be ok, contains the pdf header) im using the latest acrobat reader x
Same here. When I regenerated the pdf after cloning the git repository the pdf doc came out as around 1MB file. The checked in version is just 20Kb. Thanks for the tutorial. It is one topic that I find most difficult to grasp. Regards
Jan 15 2012
prev sibling next sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sun, Jan 15, 2012 at 11:50, d coder <dlang.coder gmail.com> wrote:

 can't open the pdf with acrobat reader under win7 :(
 (the file seems to be ok, contains the pdf header)

 im using the latest acrobat reader x
Same here. When I regenerated the pdf after cloning the git repository the pdf doc came out as around 1MB file. The checked in version is just 20Kb.
Yeah, sorry, I probably botched a github exchange when integrating yesterday's remarks. I just regenerated the pdf and tested it on both Windows and Linux, from an integrated pdf viewer in TexWorks, KDE Okular and Acrobat X and they all work. I put it in Github 5' ago. Btw, it's cool you could generate the pdf. Did you have minted and pygments already installed?
 Thanks for the tutorial. It is one topic that I find most difficult to grasp.
Don't hesitate to tell me where it's unclear. If you have any example in mind or some difficulty that constantly trip you and that does not appear in the text, send me a mail, put an issue on github or send me a pull request. Philippe
Jan 15 2012
prev sibling next sibling parent d coder <dlang.coder gmail.com> writes:
 Btw, it's cool you could generate the pdf. Did you have minted and
 pygments already installed?
No. But I downloaded minted.sty and apt-get pygmentize when pdflatex failed.
 Don't hesitate to tell me where it's unclear. If you have any example
 in mind or some difficulty that constantly trip you and that does not
 appear in the text, send me a mail, put an issue on github or send me
 a pull request.
Thanks. I have just started reading your tutorial. And I am a slow learner. Regards
Jan 15 2012
prev sibling parent reply "Nick Sabalausky" <a a.a> writes:
"dennis luehring" <dl.soluz gmx.net> wrote in message 
news:jeu3mf$94o$1 digitalmars.com...
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtemplates.pdf
...with acrobat reader...
Eewww. Do youself a favor and grab a copy of FoxIt Reader. Works just as well, but isn't an insane resource hog. Adobe == bloatware.
Jan 16 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Tue, Jan 17, 2012 at 02:49, Nick Sabalausky <a a.a> wrote:
 "dennis luehring" <dl.soluz gmx.net> wrote in message
 news:jeu3mf$94o$1 digitalmars.com...
 https://github.com/PhilippeSigaud/D-templates-tutorial/blob/master/dtem=
plates.pdf
 ...with acrobat reader...
Eewww. =C2=A0Do youself a favor and grab a copy of FoxIt Reader. Works ju=
st as
 well, but isn't an insane resource hog. Adobe =3D=3D bloatware.
I don't use it normally, but wanted to test the pdf specifically with Reader 10.x, as someone signalled a pb with it. But the pb came only from a mistake I made on github.
Jan 17 2012
prev sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2012-01-13 22:20, Philippe Sigaud wrote:
 [Cross-posted with D.learn, since it's also a learning-related post]

 Hello all,

 I discovered D a few years ago and, seeing the recent increase in community
 projects, I looked for a way to bring my own small part to it.

 I quite like D templates and wanted to try LaTeX again, so I decided to bite
the
 bullet and wrote a tutorial on templates. It's far from finished and most
probably
 full of mistakes but since it's already quite big, I need some inputs.

 It's a Github project, here:

 https://github.com/PhilippeSigaud/D-templates-tutorial

 The resulting pdf is there:

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

 (click on View Raw)

 If you have any comment, criticism, explanation, what have you, I'm game. What
 section should be expanded, what example would be cool, etc. If you see a
mistake,
 do not hesitate to tell me: it's the first time I put thoughts on paper like
this.
 Github issues management is far from perfect, but it's usable. Even better
would
 be pull requests :)

 There is an 'Examples' section where I show what can be done with templates and
 there I 'borrowed' some code posted here, with attribution. I already exchanged
 with Andrej Mitrovic (thanks!), but also took some code from Timon Gehr, Simen
 Kjaeraas, Trass3r and Jacob Carlborg. Guys, if any of you have a problem with
 that, tell me so and I'll take down the code of course. But if any of you could
 give me some explanation (a small paragraph or two?) about what your code does,
 I'll be forever grateful :)

 This also extend to anyone who would want to share some template love/lore with
 the rest of us.

 Philippe
I see that you have referenced my Orange library, cool. Looking at the example for emitting events. I'm not completely sure how it works but it looks like that Fields mixin can be replace with the code you have referenced from my Orange library and opDispatch. Then you could write the Point and Size structs just as regular structs without the mixin. -- /Jacob Carlborg
Jan 15 2012
next sibling parent reply Philippe Sigaud <philippe.sigaud gmail.com> writes:
On Sun, Jan 15, 2012 at 12:26, Jacob Carlborg <doob me.com> wrote:
 I see that you have referenced my Orange library, cool.
As for Orange, is it OK with you if I show a small part of it? Is it OK for me to link to the github project? Mainly, I wanted to show some tricks you used in util/Reflection.d and util/Traits.d. I should rummage in your code again. Btw, I think that by using the technics shown in Nick's last year article (generating switch/cases from CT information), it would be possible to make some parameters of Reflection.d be runtime parameters instead of compile-time. That is, from hasField!(T, "field") to hasField!T("field"). I do not know if for serializing it's interesting or not.
 Looking at the
 example for emitting events. I'm not completely sure how it works but it
 looks like that Fields mixin can be replace with the code you have
 referenced from my Orange library and opDispatch. Then you could write the
 Point and Size structs just as regular structs without the mixin.
This mixin comes from Andrej Mitrovic. You should see with him the difference with Orange, I admit not knowing much about this. Philippe
Jan 15 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-01-15 14:33, Philippe Sigaud wrote:
 On Sun, Jan 15, 2012 at 12:26, Jacob Carlborg<doob me.com>  wrote:
 I see that you have referenced my Orange library, cool.
As for Orange, is it OK with you if I show a small part of it? Is it OK for me to link to the github project? Mainly, I wanted to show some tricks you used in util/Reflection.d and util/Traits.d. I should rummage in your code again.
Sure, go ahead and use whatever you want :)
 Btw, I think that by using the technics shown in Nick's last year
 article (generating switch/cases from CT information), it would be
 possible to make some parameters of Reflection.d be runtime parameters
 instead of compile-time.
Do you have a link?
 That is, from hasField!(T, "field") to hasField!T("field"). I do not
 know if for serializing it's interesting or not.
It might be, depends on how the implementation look like.
 Looking at the
 example for emitting events. I'm not completely sure how it works but it
 looks like that Fields mixin can be replace with the code you have
 referenced from my Orange library and opDispatch. Then you could write the
 Point and Size structs just as regular structs without the mixin.
This mixin comes from Andrej Mitrovic. You should see with him the difference with Orange, I admit not knowing much about this. Philippe
Ok, I see. -- /Jacob Carlborg
Jan 15 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
 As for Orange, is it OK with you if I show a small part of it? Is it
 OK for me to link to the github project?
Sure, go ahead and use whatever you want :)
Thanks.
 Btw, I think that by using the technics shown in Nick's last year
 article (generating switch/cases from CT information), it would be
 possible to make some parameters of Reflection.d be runtime parameters
 instead of compile-time.
Do you have a link?
Sure: http://www.semitwist.com/articles/EfficientAndFlexible/SinglePage/#part6-3
Jan 15 2012
prev sibling parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
On 1/15/12, Jacob Carlborg <doob me.com> wrote:
 I'm not completely sure how it works but it
 looks like that Fields mixin can be replace with the code you have
 referenced from my Orange library and opDispatch.
You mean your `fieldsOf` template? I'm not really sure how that would work, I've tried this: This opBinary(string op)(This rhs) { This res; foreach (field; fieldsOf!This) { mixin("res." ~ field ~ " = this." ~ field ~ op ~ " rhs." ~ field ~ ";"); } return res; } But that gives me errors: Error: variable __aggr901 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Error: variable __key902 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Anyway that Fields mixin was something I wrote as a quick example for the book. I've also tried using traits(allMembers), but that didn't work too good.
Jan 16 2012
parent reply Jacob Carlborg <doob me.com> writes:
On 2012-01-16 12:43, Andrej Mitrovic wrote:
 On 1/15/12, Jacob Carlborg<doob me.com>  wrote:
 I'm not completely sure how it works but it
 looks like that Fields mixin can be replace with the code you have
 referenced from my Orange library and opDispatch.
You mean your `fieldsOf` template? I'm not really sure how that would work, I've tried this: This opBinary(string op)(This rhs) { This res; foreach (field; fieldsOf!This) { mixin("res." ~ field ~ " = this." ~ field ~ op ~ " rhs." ~ field ~ ";"); } return res; } But that gives me errors: Error: variable __aggr901 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Error: variable __key902 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Error: variable __aggr901 cannot be read at compile time Anyway that Fields mixin was something I wrote as a quick example for the book. I've also tried using traits(allMembers), but that didn't work too good.
This compiles and run as expected for me using dmd 2.057: http://pastebin.com/fq27831F But I was thinking if the Fields mixin is necessary at all. Since it's possible to get and set the values of structs and objects using tupleof. I was thinking it would be possible to use this technique directly in Notify. Something like this: struct Notify (T) { auto opBinary (string op, T) (T rhs) { T result; foreach (i, dummy ; T.tupleof) mixin("result.tupleof[i] = raw.tupleof[i] " ~ op ~ " rhs.tupleof[i];\n"); return result; } } -- /Jacob Carlborg
Jan 16 2012
parent reply Andrej Mitrovic <andrej.mitrovich gmail.com> writes:
Ah, I completely forgot about tupleof. That could work. Originally
I've tried __traits() but it didn't work. Thanks.
Jan 16 2012
parent Jacob Carlborg <doob me.com> writes:
On 2012-01-16 21:41, Andrej Mitrovic wrote:
 Ah, I completely forgot about tupleof. That could work. Originally
 I've tried __traits() but it didn't work. Thanks.
No problem. Although tupleof works for private and protected fields as well. Don't know if that would be a problem. -- /Jacob Carlborg
Jan 16 2012