www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Walter, question about templates

reply Deja Augustine <deja scratch-ware.net> writes:
I'm having a little difficulty implementing templates in D.NET due to a 
strange happening with the front-end.  I might just be missing 
something, but using the following sample code, here's the chain of 
events I get:

#
# template tp(T) {  T foo; }
#
# public static void main()
# {
#   tp!(int).foo = 6;
# }
#

I get:

TemplateDeclaration::toObjFile
FuncDeclaration::toObjFile
VarDeclaration::toObjFile
TemplateInstance::toObjFile

Is there a particular reason that the variable foo's declaration would 
be called BEFORE the template instance's declaration?  Or did I muck 
something up with the way my code handles things?

-Deja
Sep 16 2004
next sibling parent reply "Lynn Allan" <l_d_allan adelphia.net> writes:
Your Subject Header: seems to indicate that you are only interested in
having The WB answer your question. There are at least several people on
this list who can probably help you, and thus relieve The WB from getting
bogged down. This is a collaborative project.

HTH

"Deja Augustine" <deja scratch-ware.net> wrote in message
news:cidr47$mca$1 digitaldaemon.com...
 I'm having a little difficulty implementing templates in D.NET due to a
 strange happening with the front-end.  I might just be missing
 something, but using the following sample code, here's the chain of
 events I get:

 #
 # template tp(T) {  T foo; }
 #
 # public static void main()
 # {
 #   tp!(int).foo = 6;
 # }
 #

 I get:

 TemplateDeclaration::toObjFile
 FuncDeclaration::toObjFile
 VarDeclaration::toObjFile
 TemplateInstance::toObjFile

 Is there a particular reason that the variable foo's declaration would
 be called BEFORE the template instance's declaration?  Or did I muck
 something up with the way my code handles things?

 -Deja

Sep 17 2004
parent Deja Augustine <Deja_member pathlink.com> writes:
It occurs to me, though that most people read all of the posts.  Had I only
wanted Walter's reply I would have e-mailed him directly.  However, I prefixed
it with Walter to draw his attention to it.

-Deja

In article <cifkrc$3047$1 digitaldaemon.com>, Lynn Allan says...
Your Subject Header: seems to indicate that you are only interested in
having The WB answer your question. There are at least several people on
this list who can probably help you, and thus relieve The WB from getting
bogged down. This is a collaborative project.

HTH

"Deja Augustine" <deja scratch-ware.net> wrote in message
news:cidr47$mca$1 digitaldaemon.com...
 I'm having a little difficulty implementing templates in D.NET due to a
 strange happening with the front-end.  I might just be missing
 something, but using the following sample code, here's the chain of
 events I get:

 #
 # template tp(T) {  T foo; }
 #
 # public static void main()
 # {
 #   tp!(int).foo = 6;
 # }
 #

 I get:

 TemplateDeclaration::toObjFile
 FuncDeclaration::toObjFile
 VarDeclaration::toObjFile
 TemplateInstance::toObjFile

 Is there a particular reason that the variable foo's declaration would
 be called BEFORE the template instance's declaration?  Or did I muck
 something up with the way my code handles things?

 -Deja


Sep 17 2004
prev sibling parent reply "Walter" <newshound digitalmars.com> writes:
"Deja Augustine" <deja scratch-ware.net> wrote in message
news:cidr47$mca$1 digitaldaemon.com...
 I'm having a little difficulty implementing templates in D.NET due to a
 strange happening with the front-end.  I might just be missing
 something, but using the following sample code, here's the chain of
 events I get:

 #
 # template tp(T) {  T foo; }
 #
 # public static void main()
 # {
 #   tp!(int).foo = 6;
 # }
 #

 I get:

 TemplateDeclaration::toObjFile
 FuncDeclaration::toObjFile
 VarDeclaration::toObjFile
 TemplateInstance::toObjFile

 Is there a particular reason that the variable foo's declaration would
 be called BEFORE the template instance's declaration?  Or did I muck
 something up with the way my code handles things?

It shouldn't matter what order the toObjFile()'s are called, only that they are called. Also, there is no TemplateDeclaration::toObjFile() function. I get: FuncDeclaration::toObjFile(00A8B110, main) TemplateInstance::toObjFile('tp!(int)') VarDeclaration::toObjFile(00A8DFF4 'foo') protection 5
Sep 19 2004
parent Deja Augustine <deja scratch-ware.net> writes:
Walter wrote:

 "Deja Augustine" <deja scratch-ware.net> wrote in message
 news:cidr47$mca$1 digitaldaemon.com...
 
I'm having a little difficulty implementing templates in D.NET due to a
strange happening with the front-end.  I might just be missing
something, but using the following sample code, here's the chain of
events I get:

#
# template tp(T) {  T foo; }
#
# public static void main()
# {
#   tp!(int).foo = 6;
# }
#

I get:

TemplateDeclaration::toObjFile
FuncDeclaration::toObjFile
VarDeclaration::toObjFile
TemplateInstance::toObjFile

Is there a particular reason that the variable foo's declaration would
be called BEFORE the template instance's declaration?  Or did I muck
something up with the way my code handles things?

It shouldn't matter what order the toObjFile()'s are called, only that they are called. Also, there is no TemplateDeclaration::toObjFile() function. I get: FuncDeclaration::toObjFile(00A8B110, main) TemplateInstance::toObjFile('tp!(int)') VarDeclaration::toObjFile(00A8DFF4 'foo') protection 5

Yeah, I added TemplateDeclaration::toObjFile(). I've also figured out how the front-end handles it and have since implemented templates. Thank you, though -Deja
Sep 19 2004