On Sun, Jul 22, 2012 at 6:15 PM, Andrej Mitrovic <andrej.mitrov...@gmail.com> wrote: > On 7/22/12, Philippe Sigaud <philippe.sig...@gmail.com> wrote: >> 2) Why classes, as opposed to structs? > > I think either way you'd need reference semantics.
Yeah, I agree, reference semantics look better. And since there is a lot of duplication (struct info is a subtype of class info, itself looking very uch like a module info, I guess a mini-hierarchy is possible). So I'm convinced classes look like a good fit. > You could use structs as well, and actually I use structs in my > codegenerator (with a similar layout to what Andrei posted). Each > struct (e.g. Class/Function) stores Symbols, which are structs with an > ID and a Type. I can look up each symbol in a SymTable which actually > holds the structures with data. So a Symbol is like a fake pointer, > and the SymTable would be the memory. I originally planned to use > classes but some serialization frameworks didn't work with those so I > settled using structs and a bit of template mixin magic instead. Could you describe your design in this thread, and possibly link to some code? > All of this std.reflection talk is quite exciting actually. It is! > If you had > AST information about your entire D library you could do some really > cool things. You could make a better documentation generator than > ddoc, or export the AST into a file for a code-completion plugin, or > create a wrapper C library which enables other languages to use your D > library. You could do macros. 'nuff said.