Re: Understanding Templates: why can't anybody do it?

2012-03-23 Thread Sean Kelly
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

Re: Understanding Templates: why can't anybody do it?

2012-03-23 Thread Sean Kelly
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.

Re: Understanding Templates: why can't anybody do it?

2012-03-22 Thread Nick Sabalausky
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

Re: Understanding Templates: why can't anybody do it?

2012-03-22 Thread H. S. Teoh
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:

Re: Understanding Templates: why can't anybody do it?

2012-03-22 Thread Nick Sabalausky
H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.1037.1332480633.4860.digitalmar...@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

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread Gour
On Sun, 18 Mar 2012 11:04:45 +0100 Paulo Pinto pj...@progtools.org wrote: Enterprise software? Not here, we'll write open-source project. ;) Sincerely, Gour -- All living bodies subsist on food grains, which are produced from rains. Rains are produced by performance of yajña [sacrifice],

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread Sean Kelly
On Mar 17, 2012, at 10:14 AM, Entity325 wrote: (Sorry if this is the wrong place for this, or if there's already a thread in existence which would be better. If either of these is the case, simply point me in the right direction, and I'll be on my way.) My first interaction with

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread Andrei Alexandrescu
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

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread H. S. Teoh
On Mon, Mar 19, 2012 at 02:27:04PM -0500, Andrei Alexandrescu wrote: 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

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread Philippe Sigaud
On Mon, Mar 19, 2012 at 20:37, H. S. Teoh hst...@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

Re: Understanding Templates: why can't anybody do it?

2012-03-19 Thread Nick Sabalausky
Andrei Alexandrescu seewebsiteforem...@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

Re: Understanding Templates: why can't anybody do it?

2012-03-18 Thread Gour
On Sat, 17 Mar 2012 15:39:53 -0700 H. S. Teoh hst...@quickfur.ath.cx wrote: I don't think you can discard OOP entirely. It still has its place IMO. When you need runtime polymorphism, OOP is still the best tool for the job. Hmm, if we want to write more FP-like type-safe code, I wonder how

Re: Understanding Templates: why can't anybody do it?

2012-03-18 Thread Paulo Pinto
Am 18.03.2012 07:41, schrieb Gour: On Sat, 17 Mar 2012 15:39:53 -0700 H. S. Teohhst...@quickfur.ath.cx wrote: I don't think you can discard OOP entirely. It still has its place IMO. When you need runtime polymorphism, OOP is still the best tool for the job. Hmm, if we want to write more

Understanding Templates: why can't anybody do it?

2012-03-17 Thread Entity325
(Sorry if this is the wrong place for this, or if there's already a thread in existence which would be better. If either of these is the case, simply point me in the right direction, and I'll be on my way.) My first interaction with Templates was about 5 years ago, in a C++ class at my

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Andrei Alexandrescu
On 3/17/12 12:14 PM, Entity325 wrote: Who's with me? Anybody have a short(but COMPLETE!) example of code that makes use of Templates that you actually understand what's going on there? You're on to something here. Then, as usual, from idea to realization there are quite a few steps. I took

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Walter Bright
On 3/17/2012 10:55 AM, Andrei Alexandrescu wrote: On 3/17/12 12:14 PM, Entity325 wrote: Who's with me? Anybody have a short(but COMPLETE!) example of code that makes use of Templates that you actually understand what's going on there? You're on to something here. Then, as usual, from idea to

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Xinok
On Saturday, 17 March 2012 at 18:16:31 UTC, Walter Bright wrote: i.e. templates are type parameters. Maybe in C++. In C++, templates are attached to a class or function, where as in D, they're an independent construct. The way I think of it, templates are a tool for building static code

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Paulo Pinto
Maybe you should first try to learn some concepts about generic programming http://en.wikipedia.org/wiki/Generic_programming You will see this is nothing specific to C++ or D, and almost all modern languages do have some form of genericity. If you still cannot understand them, you cold try to

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Ali Çehreli
On 03/17/2012 10:14 AM, Entity325 wrote: Who's with me? Anybody have a short(but COMPLETE!) example of code that makes use of Templates that you actually understand what's going on there? The Templates chapter of Programming in D is supposed to be a gentle introduction to templates:

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Ali Çehreli
On 03/17/2012 12:57 PM, Ali Çehreli wrote: http://ddili.org/ders/d.en/templates.html [...] The chapter also contains a link to Philippe Sigaud's D Templates: A Tutorial. Sorry, I did not intend to leave the link to that document out:

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Max Klyga
On 2012-03-17 20:14:47 +0300, Entity325 said: Who's with me? Anybody have a short(but COMPLETE!) example of code that makes use of Templates that you actually understand what's going on there? Philippe Sigaud made a very good tutorial on templates in D -

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
Entity325 lonewolf...@gmail.com wrote in message news:pgzkvphadihglayfu...@forum.dlang.org... That is to say, nobody understands how Templates work is because, as was the case for me, the sum total of explanation we are given on them in programming class is These are Templates. They exist.

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Andrej Mitrovic
On 3/17/12, Entity325 lonewolf...@gmail.com wrote: Who's with me? Anybody have a short(but COMPLETE!) example of code that makes use of Templates that you actually understand what's going on there? I wrote this a long time ago when I was just figuring out what templates were about (it's not a

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread novice2
templates are a tool for building static code from a set of parameters. unfortunately (imho), there is no way to see the result code

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Gour
On Sat, 17 Mar 2012 21:29:18 +0100 Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I had no idea what templates were when I started using D, and I thought I would never need to use them either. But now I use them extensively. They really become a natural tool in programming. They're so nice

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread novice2
How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another more high level? Will temlate will become another language used as complete language? Will generic prigramming become mainstream,

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Paulo Pinto
Am 17.03.2012 21:20, schrieb Nick Sabalausky: Entity325lonewolf...@gmail.com wrote in message news:pgzkvphadihglayfu...@forum.dlang.org... That is to say, nobody understands how Templates work is because, as was the case for me, the sum total of explanation we are given on them in programming

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Simen Kjærås
On Sat, 17 Mar 2012 21:56:14 +0100, novice2 so...@noem.ail wrote: How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another more high level? Will temlate will become another language

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Paulo Pinto
Am 17.03.2012 21:56, schrieb novice2: How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another more high level? Will temlate will become another language used as complete language? Will

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Simen Kjærås
On Sat, 17 Mar 2012 22:16:37 +0100, Paulo Pinto pj...@progtools.org wrote: Am 17.03.2012 21:56, schrieb novice2: How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another more high level?

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Simen Kjærås
On Sat, 17 Mar 2012 21:20:42 +0100, Nick Sabalausky a@a.a wrote: I've spent a total of about 6 years in college, always got A's and B's in the CS classes, and yet I'm convinced that programming classes are completely and utterly useless. Most of the instructors themselves barely even know how

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Paulo Pinto
Am 17.03.2012 22:19, schrieb Simen Kjærås: On Sat, 17 Mar 2012 22:16:37 +0100, Paulo Pinto pj...@progtools.org wrote: Am 17.03.2012 21:56, schrieb novice2: How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler.

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread H. S. Teoh
On Sat, Mar 17, 2012 at 10:13:44PM +0100, Paulo Pinto wrote: Am 17.03.2012 21:20, schrieb Nick Sabalausky: [...] I've spent a total of about 6 years in college, always got A's and B's in the CS classes, and yet I'm convinced that programming classes are completely and utterly useless. Most of

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread H. S. Teoh
On Sat, Mar 17, 2012 at 10:15:26PM +0100, Simen Kjærås wrote: On Sat, 17 Mar 2012 21:56:14 +0100, novice2 so...@noem.ail wrote: How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread H. S. Teoh
On Sat, Mar 17, 2012 at 09:45:51PM +0100, Gour wrote: On Sat, 17 Mar 2012 21:29:18 +0100 Andrej Mitrovic andrej.mitrov...@gmail.com wrote: I had no idea what templates were when I started using D, and I thought I would never need to use them either. But now I use them extensively. They

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Jos van Uden
On 17-3-2012 21:20, Nick Sabalausky wrote: Here's a little templates primer, I hope it helps: [...] Part of this primer would serve well as introduction to Phillipe's tutorial, because it skips the basics. (I knew the basics, but not everybody does.) Jos

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Entity325
Wow, popular thread is popular. Thanks for all the help, everyone. I haven't read all of it, but I will take the time to sift through everything and see what I can apply. Response to some of what I did read: -I didn't conclude that templates are confusing because they confused me. I

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.834.1332023905.4860.digitalmar...@puremagic.com... (Not to mention, D templates can do some stuff that no OO can hope to attain. But it goes both ways. Templates can't do runtime polymorphism either.) Combined with compile-time

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread H. S. Teoh
On Sat, Mar 17, 2012 at 08:37:35PM -0400, Nick Sabalausky wrote: H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.834.1332023905.4860.digitalmar...@puremagic.com... (Not to mention, D templates can do some stuff that no OO can hope to attain. But it goes both ways.

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
Entity325 lonewolf...@gmail.com wrote in message news:vxadflowsujbbmpnr...@forum.dlang.org... -While most of my programming professors had a decent idea of what they were doing, the classes themselves left massive, gaping holes in my education that I never even realized were there until I

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
Simen Kjærås simen.kja...@gmail.com wrote in message news:op.wbb24i010gp...@biotronic.lan... On Sat, 17 Mar 2012 21:20:42 +0100, Nick Sabalausky a@a.a wrote: I've spent a total of about 6 years in college, always got A's and B's in the CS classes, and yet I'm convinced that programming

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.839.1332031513.4860.digitalmar...@puremagic.com... On Sat, Mar 17, 2012 at 08:37:35PM -0400, Nick Sabalausky wrote: H. S. Teoh hst...@quickfur.ath.cx wrote in message news:mailman.834.1332023905.4860.digitalmar...@puremagic.com...

Re: Understanding Templates: why can't anybody do it?

2012-03-17 Thread Nick Sabalausky
novice2 so...@noem.ail wrote in message news:hzbmfpsyzezjwzshx...@forum.dlang.org... How it come, that we build another abstartion level above strong typed language? Onece we builded high level language above assembler. Are we now building another more high level? Will temlate will become