D - typeof equivalent?
- Russell Lewis (3/3) Nov 12 2002 Does DMD or DLI implement an equivalent of gcc's typeof() operator? I
- Burton Radons (5/8) Nov 12 2002 ".typeinfo" for a TypeInfo instance, ".classinfo" for a ClassInfo
- Evan McClanahan (5/18) Nov 12 2002 are .typeinfo and .classinfo documented anywhere? It would be nice to
- Walter (4/7) Dec 15 2002 They're in phobos/object.d, but you're right, they need to be better
- Russ Lewis (20/28) Apr 05 2003 Came across this again. I had an automatically generated type. The pro...
- Mike Wynn (24/53) Apr 05 2003 program
- Lloyd Dupont (2/5) Nov 12 2002 myObject.classinfo
Does DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.
Nov 12 2002
Russell Lewis wrote:Does DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.".typeinfo" for a TypeInfo instance, ".classinfo" for a ClassInfo instance. If you mean for declarations: typeof (x) y; Then no, there's nothing of the sort. What are you trying to use it in?
Nov 12 2002
Burton Radons wrote:Russell Lewis wrote:are .typeinfo and .classinfo documented anywhere? It would be nice to have some more solid information on them, and I can't find it anywnere in the spec. EvanDoes DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.".typeinfo" for a TypeInfo instance, ".classinfo" for a ClassInfo instance. If you mean for declarations: typeof (x) y; Then no, there's nothing of the sort. What are you trying to use it in?
Nov 12 2002
"Evan McClanahan" <evan dontSPAMaltarinteractive.com> wrote in message news:aqrfas$j2k$1 digitaldaemon.com...are .typeinfo and .classinfo documented anywhere? It would be nice to have some more solid information on them, and I can't find it anywnere in the spec.They're in phobos/object.d, but you're right, they need to be better documented.
Dec 15 2002
Burton Radons wrote:Russell Lewis wrote:Came across this again. I had an automatically generated type. The program that references it doesn't know anything about the type, or its type name, except that it is an array of structs, and some of the member names inside the struct. The user code can do this: for(int b=0; b<foo.bars.length; b++) DoStuff(foo.bars[b].baz); I would like to decare, in user code, an array of the same type without requiring that the user code know the internal naming scheme of the code generator. Something like this: typeof(foo.bars[0])[] mySlice = foo.bars[2..5]; As far as I can see, there is no good alternative to typeof() here...anything else requires that the user code know the internal naming scheme of the code generator. -- The Villagers are Online! http://villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ]Does DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.".typeinfo" for a TypeInfo instance, ".classinfo" for a ClassInfo instance. If you mean for declarations: typeof (x) y; Then no, there's nothing of the sort. What are you trying to use it in?
Apr 05 2003
"Russ Lewis" <spamhole-2001-07-16 deming-os.org> wrote in message news:3E8EDE59.DABF2286 deming-os.org...Burton Radons wrote:programRussell Lewis wrote:Came across this again. I had an automatically generated type. TheDoes DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.".typeinfo" for a TypeInfo instance, ".classinfo" for a ClassInfo instance. If you mean for declarations: typeof (x) y; Then no, there's nothing of the sort. What are you trying to use it in?that references it doesn't know anything about the type, or its type name, except that it is an array of structs, and some of the member names inside the struct. The user code can do this: for(int b=0; b<foo.bars.length; b++) DoStuff(foo.bars[b].baz); I would like to decare, in user code, an array of the same type without requiring that the user code know the internal naming scheme of the code generator. Something like this: typeof(foo.bars[0])[] mySlice = foo.bars[2..5]; As far as I can see, there is no good alternative to typeof() here...anything else requires that the user code know the internal naming scheme of the code generator.I started thinking along these lines .... how about a template with a value type thus; // the generated type; struct gen_type_001 { ... } // generated template template gen_array( gen_type_001 match ) { alias gen_type_001 []array_type; } // another generated type and template. struct gen_type_002 { ... } template gen_array( gen_type_002 match ) { alias gen_type_002 []array_type; } then realised ...for(int b=0; b<foo.bars.length; b++) DoStuff(foo.bars[b].baz); typeof(foo.bars[0])[] mySlice = foo.bars[2..5];whats foo where is it declared. statically typed langs require it to be declared somewhere visible to the user. the obvious solution is to use a hashtable `Object[char[]] map` so foo.bars is a Object[char[]] [] (think that's right : array of assoc array (maps char[] to Object) and use foo.bars[b]["baz"]
Apr 05 2003
Russell Lewis wrote:Does DMD or DLI implement an equivalent of gcc's typeof() operator? I think that something like this should be a part of the language spec. It's very useful, at times.myObject.classinfo
Nov 12 2002