www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - SDWest paper "Templates Revisited" now available

reply "Walter Bright" <newshound digitalmars.com> writes:
www.digitalmars.com/d/templates-revisited.html 
Mar 17 2006
next sibling parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
Walter Bright wrote:
 www.digitalmars.com/d/templates-revisited.html 
 
 
Nice! not that I'm into templates or anything .. note: somethings are duplicated, for example, this segment: ------- Partial and explicit specialization work as they do in C++, except that there is no notion of a 'primary' template in D. All the templates with the same name are examined upon template instantiation, and the one with the best fit of arguments to parameters is instantiated. Specialization Partial and explicit specialization work as they do in C++, except that there is no notion of a 'primary' template. All the templates with the same name are examined upon template instantiation, and the one with the best fit of arguments to parameters is instantiated. -------------- and this one: ---------- import std.stdio; import regex; void main() { auto exp = &regexMatch!(r"[a-z]*\s*\w*"); writefln("matches: %s", exp("hello world")); } What follows is a cut-down version of Eric Andertons regex compiler. It is just enough to compile the regular expression above, serving to illustrate how it is done. -------------------
Mar 18 2006
prev sibling next sibling parent reply Lars Ivar Igesund <larsivar igesund.net> writes:
Walter Bright wrote:

 www.digitalmars.com/d/templates-revisited.html
So, how did it go? :)
Mar 18 2006
parent reply "Walter Bright" <newshound digitalmars.com> writes:
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message 
news:dvgjoj$1nd2$1 digitaldaemon.com...
 Walter Bright wrote:

 www.digitalmars.com/d/templates-revisited.html
So, how did it go? :)
It wasn't well attended because the conference people scheduled it at the same time as David Abraham's talk on templates *and* Stephen Dewhurst's template class. Anyone interested in template programming would have had a hard time picking between the three. The people who did attend, however, really enjoyed it and it was well received by them.
Mar 18 2006
parent reply pragma <pragma_member pathlink.com> writes:
In article <dvhesn$2u2t$1 digitaldaemon.com>, Walter Bright says...
"Lars Ivar Igesund" <larsivar igesund.net> wrote in message 
news:dvgjoj$1nd2$1 digitaldaemon.com...
 Walter Bright wrote:

 www.digitalmars.com/d/templates-revisited.html
So, how did it go? :)
It wasn't well attended because the conference people scheduled it at the same time as David Abraham's talk on templates *and* Stephen Dewhurst's template class. Anyone interested in template programming would have had a hard time picking between the three.
Yikes, who was the brainiac that devised that schedule?! That's a shame. Well, as they say: "there's no such thing as bad publicity". And with that, I am *very* grateful that you cited me in your paper. Thank you Walter.
The people who did attend, however, really enjoyed it and it was well 
received by them. 
Fantastic. - EricAnderton at yahoo
Mar 18 2006
parent "Walter Bright" <newshound digitalmars.com> writes:
"pragma" <pragma_member pathlink.com> wrote in message 
news:dvhufj$i4c$1 digitaldaemon.com...
 Well, as they say: "there's no such thing as bad publicity".  And with 
 that, I
 am *very* grateful that you cited me in your paper.  Thank you Walter.
You did the work, Eric. Of course you'll get the credit.
Mar 18 2006
prev sibling next sibling parent reply Dave <Dave_member pathlink.com> writes:
In article <dvgeh5$18j9$1 digitaldaemon.com>, Walter Bright says...
www.digitalmars.com/d/templates-revisited.html 
Very cool stuff! For v0.149, I had to change 'const sqrt' to 'const real sqrt' and 'const hash' to 'const real hash' for those examples. Also on Linux for the sqrt example, I'm getting these linker errors: t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte+0x0): first defined here t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte+0x0): first defined here t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte+0x0): first defined here t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee05050505050505b5ff3fVi3Z4sqrte+0x0): first defined here t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee00000000000000c0ff3fVi1Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee00000000000000c0ff3fVi1Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee00000000000000c0ff3fVi1Z4sqrte+0x0): first defined here t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte+0x0): multiple definition of `_D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte' t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee56555555555555b5ff3fVi2Z4sqrte+0x0): first defined here Thanks, - Dave
Mar 18 2006
parent Thomas Kuehne <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave schrieb am 2006-03-18:
 In article <dvgeh5$18j9$1 digitaldaemon.com>, Walter Bright says...
www.digitalmars.com/d/templates-revisited.html 
Very cool stuff! For v0.149, I had to change 'const sqrt' to 'const real sqrt' and 'const hash' to 'const real hash' for those examples.
Added to DStress as http://dstress.kuehne.cn/run/a/auto_17_A.d http://dstress.kuehne.cn/run/a/auto_17_B.d http://dstress.kuehne.cn/run/a/auto_17_C.d http://dstress.kuehne.cn/run/a/auto_17_D.d http://dstress.kuehne.cn/run/a/auto_17_E.d http://dstress.kuehne.cn/run/a/auto_17_F.d http://dstress.kuehne.cn/run/c/const_36_A.d http://dstress.kuehne.cn/run/c/const_36_B.d http://dstress.kuehne.cn/run/c/const_36_C.d http://dstress.kuehne.cn/run/c/const_36_D.d http://dstress.kuehne.cn/run/c/const_36_E.d http://dstress.kuehne.cn/run/c/const_36_F.d http://dstress.kuehne.cn/run/c/const_36_G.d http://dstress.kuehne.cn/run/c/const_36_H.d http://dstress.kuehne.cn/run/c/const_36_I.d http://dstress.kuehne.cn/run/c/const_37_A.d http://dstress.kuehne.cn/run/c/const_37_B.d http://dstress.kuehne.cn/run/c/const_37_C.d http://dstress.kuehne.cn/run/c/const_37_D.d http://dstress.kuehne.cn/run/c/const_37_E.d http://dstress.kuehne.cn/run/c/const_37_F.d http://dstress.kuehne.cn/run/s/static_36_A.d http://dstress.kuehne.cn/run/s/static_36_B.d http://dstress.kuehne.cn/run/s/static_36_C.d http://dstress.kuehne.cn/run/s/static_36_D.d http://dstress.kuehne.cn/run/s/static_36_E.d http://dstress.kuehne.cn/run/s/static_36_F.d
 Also on Linux for the sqrt example, I'm getting these linker errors:

 t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte+0x0):
 multiple definition of `_D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte'
 t.o(.gnu.linkonce.d._D1t38__T4sqrtVi2Vee78d9befa33f304b5ff3fVi4Z4sqrte+0x0):
 first defined here
[snip] Added to DStress as http://dstress.kuehne.cn/run/t/template_32_A.d http://dstress.kuehne.cn/run/t/template_32_B.d http://dstress.kuehne.cn/run/t/template_32_C.d http://dstress.kuehne.cn/run/t/template_32_D.d http://dstress.kuehne.cn/run/t/template_32_E.d http://dstress.kuehne.cn/run/t/template_32_F.d http://dstress.kuehne.cn/run/t/template_32_G.d http://dstress.kuehne.cn/run/t/template_32_H.d http://dstress.kuehne.cn/run/t/template_32_I.d http://dstress.kuehne.cn/run/t/template_32_J.d http://dstress.kuehne.cn/run/t/template_32_K.d http://dstress.kuehne.cn/run/t/template_32_L.d http://dstress.kuehne.cn/run/t/template_32_M.d http://dstress.kuehne.cn/run/t/template_32_N.d http://dstress.kuehne.cn/run/t/template_32_O.d http://dstress.kuehne.cn/run/t/template_32_P.d http://dstress.kuehne.cn/run/t/template_32_Q.d http://dstress.kuehne.cn/run/t/template_32_R.d http://dstress.kuehne.cn/run/t/template_32_S.d http://dstress.kuehne.cn/run/t/template_32_T.d http://dstress.kuehne.cn/run/t/template_32_U.d http://dstress.kuehne.cn/run/t/template_33_A.d http://dstress.kuehne.cn/run/t/template_33_B.d http://dstress.kuehne.cn/run/t/template_33_C.d http://dstress.kuehne.cn/run/t/template_33_D.d http://dstress.kuehne.cn/run/t/template_33_E.d http://dstress.kuehne.cn/run/t/template_33_F.d http://dstress.kuehne.cn/run/t/template_33_G.d http://dstress.kuehne.cn/run/t/template_33_H.d http://dstress.kuehne.cn/run/t/template_33_I.d Might be related: http://dstress.kuehne.cn/www/dstress.html#template_class_14_A http://dstress.kuehne.cn/www/dstress.html#template_struct_05_C Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEHCsF3w+/yD4P9tIRAntDAJ43e56qVZMg55mlvm1Gl5id6oULIQCfZ10c /s1LswTx9HzYhGPnTK91xkA= =NBdW -----END PGP SIGNATURE-----
Mar 18 2006
prev sibling next sibling parent =?ISO-8859-1?Q?Anders_F_Bj=F6rklund?= <afb algonet.se> writes:
Walter Bright wrote:

 www.digitalmars.com/d/templates-revisited.html 
Interesting paper, it really makes me wish that the templates were actually working on my Mac OS X 10.3... It's working with GCC 4.x, just that I'm not there yet. (guess we need a port for GCC 3.x, from Apple's sources) So for now, I'll just have to stay clear of them... :-( --anders
Mar 18 2006
prev sibling next sibling parent reply John Demme <me teqdruid.com> writes:
Walter Bright wrote:

 www.digitalmars.com/d/templates-revisited.html
"Printf Revisited".... "Templates Revisited"... Will your book on D programming be called "Programming Revisited"? Good stuff, BTW. I may be doing your NW C++ presentation for my LUG here at University of Maryland, and follow it up with this one. ~John Demme
Mar 18 2006
parent Kyle Furlong <kylefurlong gmail.com> writes:
John Demme wrote:
 Walter Bright wrote:
 
 www.digitalmars.com/d/templates-revisited.html
"Printf Revisited".... "Templates Revisited"... Will your book on D programming be called "Programming Revisited"? Good stuff, BTW. I may be doing your NW C++ presentation for my LUG here at University of Maryland, and follow it up with this one. ~John Demme
That would be fantastic, I think if we could all do things like this it would really help to evangelize.
Mar 19 2006
prev sibling parent Bruno Medeiros <brunodomedeirosATgmail SPAM.com> writes:
Both in the D doc, and in
www.digitalmars.com/d/templates-revisited.html
the rules about template specialization are omissive about alias 
parameters. I think a clarification is important, even more because the 
actual behavior seems a bit strange to me. See the code below.


class Foo { }	
	
class FooBar : Foo {}

template Xpto(T:FooBar) {
   int a = 1;
}

template Xpto(alias T) {
   int a = 2;
}

template Xpto(T:Foo) {
   int a = 3;
}

template Xpto(T) {
   int a = 4;
}

int main(char[][] args)
{
   writefln( Xpto!(FooBar).a );
}


The templates are shown ordered according to the order of preference in 
which they are chosen to specialize the Xpto!(FooBar) instance. As you 
can see the alias parameter is in the middle of the preference order, 
which seems strange to me. Shouldn't it be the first, or the last? (the 
last more likely, since it is less specific than a type parameter)

-- 
Bruno Medeiros - CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D
Apr 09 2006