Can someone explain how mixin is implemented?
Matthew Ong
ongbp at yahoo.com
Wed May 18 06:45:56 PDT 2011
Hi,
From what I can see mixin in D is used in place of #define in
C++(cool!!!). However, I do have a few question.
mixin with template does address some of this issue I supposed. That
does allow me to define up to level of content of a class but is not
class itself.
mixin template AType(T){ // but does not seems to allow me to inherit
ClassC this level.
private:
T value;
public:
this(){...}
void print(){...}
}
class ClassB : ClassC{ // ClassC Inheritance/Interface must only be done
at this level?
mixin AType!(string); // content
}
Perhaps I am missing something here. How can class level definition be
part of the mixin?
Does mixin generate the same binary code as #define as inline code,which
meant that same binary is repeated everywhere that macro is used?
Or does it make a linked to the in a centralized locations that allow
binary sharing when it is the same typed T??
--
Matthew Ong
email: ongbp at yahoo.com
More information about the Digitalmars-d-learn
mailing list