www.digitalmars.com         C & C++   DMDScript  

D - Real world D Template Examples?

reply John Reimer <jjreimer telus.net> writes:
I'm studying D templates, and trying to get a feel for them.  But the D 
documentation is just too concise to get a real picture of how they are 
used (for me, anyway).  Does anybody know of some real examples that I 
could look at, something like a vecotr or linked list sample?  Thanks!

Later,

John
Sep 27 2003
next sibling parent reply "Andrew Edwards" <edwardsac spamfreeusa.com> writes:
JR> "John Reimer" wrote in message news:bl4rb4$2r5n$1 digitaldaemon.com...
JR> I'm studying D templates, and trying to get a feel for them.  But the D
JR> documentation is just too concise to get a real picture of how they are
JR> used (for me, anyway).  Does anybody know of some real examples that I
JR> could look at, something like a vecotr or linked list sample?  Thanks!

Sorry! Don't have an example of vector or linked list. However, here's an
example of a stack.

Hope it helps.

TO COMPILE: dmd teststack stack

Regards,
Andrew


begin 666 testStack.d
M+R\M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2T-"B\O("!&:6QE("  ("  ("  
M(#H
M;V8 =&AE('-T86-K($%$5 T*+R\ ($%U=&AO<B  ("  ("  .B!!;F1R97< 

M"B\O+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM


M=&%N8V4 7U-T86-K*&-H87(I+E-T86-K(&-H87)3=&%C:SL-"B  8VAA<E-T
M86-K(&UY4W1A8VL /2!N97< 8VAA<E-T86-K.PT*("!C:&%R6UT 97AP<F5S
M<VEO;CL-"B  1FEL92!F:6QE(#T


M9FEL92YE;V8H*2D-"B  >PT*("  (&5X<')E<W-I;VX /2!F:6QE+G)E861,

M:6]N+FQE;F=T:#L
M<VEO;EMI72D-"B  ("  ('L-"B  ("  ("  8V%S92 G6R<Z(&UY4W1A8VLN

M.B!M>5-T86-K+G!U<V H97AP<F5S<VEO;EMI72D[(&)R96%K.PT*("  ("  
M("!C87-E("<H)SH ;7E3=&%C:RYP=7-H*&5X<')E<W-I;VY;:5TI.R!B<F5A

M9BAM>5-T86-K+F=E=%1O<" I(#T





M("  ("  ("  ;7E3=&%C:RYP;W H*3L-"B  ("  ("  ("  (&)R96%K.PT*

M("  ("  ("  9V]T;R!U;F)A;&%N8V5D.PT*("  ("  ("  ('T-"B  ("  
M("  ?0T*("  ("  ("!C87-E("<I)SH-"B  ("  ("  >PT*("  ("  ("  
M(&EF*&UY4W1A8VLN9V5T5&]P*"D /3T )R G*0T*("  ("  ("  ('L-"B  


M("  ("  ("  (&=O=&\ =6YB86QA;F-E9#L-



M("  <')I;G1F*"));G9A;&ED(EQN*3L-"B  ?0T*("!F:6QE+F-L;W-E*"D[


1.PT*("!R971U<FX ,#L-"GT`
`
end

begin 666 expression.txt

`
end

begin 666 stack.d
M+R\M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM
M+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2T-"B\O("!&:6QE("  ("  ("  
M(#H <W1A8VLN9 T*+R\-"B\O("!!<G)A>2!I;7!L96UE;G1A=&EO;B!O9B!T

M($5D=V%R9',-"B\O("!$871E($-R96%T960 (#H
M+RTM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM+2TM




M(" A:7-%;7!T>2 I*0T*("  ("  ("  (')E='5R;B!T:&ES4W1A8VM;=&AI

M*0T*("  ("  >PT*("  ("  ("!T:&ES4W1A8VL /2!T:&ES4W1A8VM;,"XN

M+FQE;F=T:"TM.PT*("  ("  ?0T*("  ("  =F]I9"!P=7-H*&14>7!E(&YE

M:RYL96YG=& K*UT /2!N97=$871A.PT*("  ("  ("!T:&ES4W1A8VL ?CT 
M;F5W1&%T83L-"B  ("  ('T-"B  ("  (&)I="!I<T5M<'1Y*"D-"B  ("  
M('L-"B  ("  ("  <F5T=7)N("AT:&ES4W1A8VLN;&5N9W1H(#T
M("  ("  ?0T*("  ("  :6YT('-I>F4H*0T*("  ("  >PT*("  ("  ("!R
M971U<FX =&AI<U-T86-K+FQE;F=T:#L-"B  ("  ('T-"B  ("!P<FEV871E

`
end
Sep 27 2003
next sibling parent John Reimer <jjreimer telus.net> writes:
 Sorry! Don't have an example of vector or linked list. However, here's an
 example of a stack.
 
 Hope it helps.
 
 TO COMPILE: dmd teststack stack
 
 Regards,
 Andrew
 
 
 
 5 * ( 9 +5 ) - 4
 (4 + 8) * 3 (
 {[8-1)-7}
Oh, that's quite good enough! I just wanted an example of one of the basic data structures, so a stack certainly qualifies. Thank you very much. I'll take a look at that. Later, John
Sep 27 2003
prev sibling parent John Reimer <jjreimer telus.net> writes:
The class in template construction was exactly what I was interested in. 
  So your stuff answered my question well.  Thanks.  I had a vector 
class half-implemented that way, but wasn't sure if I was doing it right 
:-).

Later,

John
Sep 27 2003
prev sibling parent reply Mike Wynn <mike l8night.co.uk> writes:
John Reimer wrote:
 I'm studying D templates, and trying to get a feel for them.  But the D 
 documentation is just too concise to get a real picture of how they are 
 used (for me, anyway).  Does anybody know of some real examples that I 
 could look at, something like a vecotr or linked list sample?  Thanks!
 
 Later,
 
 John
 
and if you are interested in template param matching here's an example of how to use templates with various params (such as a value to determine calling conventions etc) should still compile, I've been on linux since 0.70 (and this is very win32 specific, last build on 0.69) have you looked at Deimos (check the D links) I belive all the templated classes you are interested in have already been done.
Sep 27 2003
next sibling parent John Reimer <jjreimer telus.net> writes:
 and if you are interested in template param matching
 here's an example of how to use templates with various params (such as a 
 value to determine calling conventions etc)
 should still compile, I've been on linux since 0.70 (and this is very 
 win32 specific, last build on 0.69)
Anything I can get is great! Thanks!
 
 have you looked at Deimos (check the D links) I belive all the templated 
 classes you are interested in have already been done.
 
No, I haven't looked at that. I'll definitely study Deimos too. Later, John
Sep 27 2003
prev sibling parent reply John Reimer <jjreimer telus.net> writes:
Mike Wynn wrote:
 
 have you looked at Deimos (check the D links) I belive all the templated 
 classes you are interested in have already been done.
 
Now that I've had a look, Deimos appears to be in the early stages of development, and doesn't appear to have any of these data structures implemented, but it is a excellent source of D template examples, so that's good. These sources have certainly given me enough to go on :). Later, John
Sep 27 2003
parent "Daniel Yokomiso" <daniel_yokomiso yahoo.com.br> writes:
"John Reimer" <jjreimer telus.net> escreveu na mensagem
news:bl5g45$k95$1 digitaldaemon.com...
 Mike Wynn wrote:
 have you looked at Deimos (check the D links) I belive all the templated
 classes you are interested in have already been done.
Now that I've had a look, Deimos appears to be in the early stages of development, and doesn't appear to have any of these data structures implemented, but it is a excellent source of D template examples, so that's good. These sources have certainly given me enough to go on :).
That's truth, Deimos is currently at 0.0.1. I'm struggling to upgrade it to 0.0.2 but unfortunately the compiler don't agree with me sometimes ;) Probably data structures will appear in 0.0.3. 0.0.2 will include some numeric templates, but in 0.0.3 we'll have a pretty large collections module.
 Later,

 John
Best regards, Daniel Yokomiso. "Why aren't you using D by the way? If you like a C-syntax language with design by contract it seems a perfectly good choice. Why turn Eiffel into D when D is already there?" - Franck Arnaud --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.521 / Virus Database: 319 - Release Date: 23/9/2003
Sep 28 2003