digitalmars.D - Where in docs?
- Paul Runde (18/18) Jun 13 2004 This works:
- J C Calvarese (25/50) Jun 13 2004 I think you've discovered another undocumented template trick.
-
Carlos Santander B.
(39/39)
Jun 13 2004
"J C Calvarese"
escribió en el mensaje - J C Calvarese (8/49) Jun 13 2004 It may have been mentioned before. My point was that I couldn't find it
-
Carlos Santander B.
(14/14)
Jun 14 2004
"J C Calvarese"
escribió en el mensaje - J Anderson (9/14) Jun 15 2004 I suggest writing the amendment and sending it to the bugs forum.
This works: struct foo(T) { T x; void getsize() { printf("%d\n", x.size); } } void main(char[][] args) { foo!(int) y; y.getsize(); } I would just like to know where in the documentation this kind of generic programming is listed or if it is listed at all. Thanks, Paul
Jun 13 2004
Paul Runde wrote:This works: struct foo(T) { T x; void getsize() { printf("%d\n", x.size); } } void main(char[][] args) { foo!(int) y; y.getsize(); } I would just like to know where in the documentation this kind of generic programming is listed or if it is listed at all. Thanks, PaulI think you've discovered another undocumented template trick. It should be mentioned on http://www.digitalmars.com/d/template.html, but the closest thing seems to be: <quote> If a template declares exactly one member, and that member is a class with the same name as the template: template Bar(T) { class Bar { T member; } } then the semantic equivalent, called a ClassTemplateDeclaration can be written as: class Bar(T) { T member; } </quote> -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jun 13 2004
"J C Calvarese" <jcc7 cox.net> escribió en el mensaje news:caj2tv$1use$1 digitaldaemon.com | Paul Runde wrote: || This works: || || struct foo(T) || { || T x; || || void getsize() || { || printf("%d\n", x.size); || } || } || || || void main(char[][] args) || { || foo!(int) y; || y.getsize(); || } || || I would just like to know where in the documentation this kind of || generic programming is listed or if it is listed at all. || || Thanks, || || Paul | | I think you've discovered another undocumented template trick. | | ... | | -- | Justin (a/k/a jcc7) | http://jcc_7.tripod.com/d/ Where's the trick? struct templates? I think that's been mentioned before... ----------------------- Carlos Santander Bernal
Jun 13 2004
Carlos Santander B. wrote:"J C Calvarese" <jcc7 cox.net> escribió en el mensaje news:caj2tv$1use$1 digitaldaemon.com | Paul Runde wrote: || This works: || || struct foo(T) || { || T x; || || void getsize() || { || printf("%d\n", x.size); || } || } || || || void main(char[][] args) || { || foo!(int) y; || y.getsize(); || } || || I would just like to know where in the documentation this kind of || generic programming is listed or if it is listed at all. || || Thanks, || || Paul | | I think you've discovered another undocumented template trick. | | ... | | -- | Justin (a/k/a jcc7) | http://jcc_7.tripod.com/d/ Where's the trick? struct templates? I think that's been mentioned before... ----------------------- Carlos Santander BernalIt may have been mentioned before. My point was that I couldn't find it in the docs. I think it was possible to do the similar class syntax before it was documented. If a similar thing can be done with structs now, it should be documented. -- Justin (a/k/a jcc7) http://jcc_7.tripod.com/d/
Jun 13 2004
"J C Calvarese" <jcc7 cox.net> escribió en el mensaje news:caj93p$2aph$1 digitaldaemon.com | | It may have been mentioned before. My point was that I couldn't find it | in the docs. I think it was possible to do the similar class syntax | before it was documented. If a similar thing can be done with structs | now, it should be documented. | | -- | Justin (a/k/a jcc7) | http://jcc_7.tripod.com/d/ You're right. ----------------------- Carlos Santander Bernal
Jun 14 2004
J C Calvarese wrote:Carlos Santander B. wrote: It may have been mentioned before. My point was that I couldn't find it in the docs. I think it was possible to do the similar class syntax before it was documented. If a similar thing can be done with structs now, it should be documented.I suggest writing the amendment and sending it to the bugs forum. Parhaps there should be a d documentation amendments newsgroup. I mean, we don't get many now but if there was one I'm sure there would be many more if there was a place for it. I'm sure that would be a big help to Walter. I'll start a new thread on that matter. -- -Anderson: http://badmama.com.au/~anderson/
Jun 15 2004