mobiphil
2015-01-22 23:19:16 UTC
Hi there,
maybe somebody can join and help with this following brainstorming, may
sound naive, but would love to hear opinions.
Two new keywords: (white and black), or (iface and impl) or anything else,
I will go for the moment with two rather neutral keywords black and white.
Black is for blackbox, white is for whitebox. Black is for what you hide,
white is what you show. Black is really private, white is really public. No
more pimpl, guaranteed fast compilation times, less recompilation and the
list does not stop here.
// content of A.h
class white A {
/* here come all public virtuals and non virtuals */
/* we could also allow public data members */
};
// content of A.cpp
class black A {
/* here come all data members */
/* here come all the private methods */
};
/* how would I solve */
A * = new A();
what do we need for allocation? The size of the data members from white and
black? Compiler can either generate a classsize() function or with -fPIC
trick, put the size into data section, so that it can be available at
runtime. Advantage of a classize() function is that like this, classes can
have an easier life in shared libraries (plugin pattern for instance).
What about allocating on the stack? Do the same in alloca style.
What about subclassing? Well here are two problems: the size and the
offsets.
Subclass size: For the subclass the classize will be it's size plus the
data it defines additionally.
Offsets: we either force all the public data members into the blackbox (so
only private data members, thus defined in black), and outside world does
not have to know about offsets, everything will be accessed only through
getters/setters. Or one can use the normal offset calculation like for
normal classes, one can make the convention that "white" members are at the
beginning of the object. The problem would be a bit tricky with subclasses.
But also here the compiler can calculate offests as: offset in subclass +
size of baseclass.
thanks for your feedback
maybe somebody can join and help with this following brainstorming, may
sound naive, but would love to hear opinions.
Two new keywords: (white and black), or (iface and impl) or anything else,
I will go for the moment with two rather neutral keywords black and white.
Black is for blackbox, white is for whitebox. Black is for what you hide,
white is what you show. Black is really private, white is really public. No
more pimpl, guaranteed fast compilation times, less recompilation and the
list does not stop here.
// content of A.h
class white A {
/* here come all public virtuals and non virtuals */
/* we could also allow public data members */
};
// content of A.cpp
class black A {
/* here come all data members */
/* here come all the private methods */
};
/* how would I solve */
A * = new A();
what do we need for allocation? The size of the data members from white and
black? Compiler can either generate a classsize() function or with -fPIC
trick, put the size into data section, so that it can be available at
runtime. Advantage of a classize() function is that like this, classes can
have an easier life in shared libraries (plugin pattern for instance).
What about allocating on the stack? Do the same in alloca style.
What about subclassing? Well here are two problems: the size and the
offsets.
Subclass size: For the subclass the classize will be it's size plus the
data it defines additionally.
Offsets: we either force all the public data members into the blackbox (so
only private data members, thus defined in black), and outside world does
not have to know about offsets, everything will be accessed only through
getters/setters. Or one can use the normal offset calculation like for
normal classes, one can make the convention that "white" members are at the
beginning of the object. The problem would be a bit tricky with subclasses.
But also here the compiler can calculate offests as: offset in subclass +
size of baseclass.
thanks for your feedback
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.