www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Grouping code

reply Joey Peters <Joey_member pathlink.com> writes:
Hello. 
 
I'm updating my STL, and I was getting into problems again (though now
I 
understand it a lot better). Right now I want to group some parts of the code
in the following way: 
 
#class Aclass { 
#public: 






 
So I can do 
 
Aclass a =
new Aclass; 
a.anamespace.something(); 
 
Maybe that sounds a bit weird but I
try to be a perfectionist right now ;). 
Anyway, the problem is accessing
'this'. Like in function 'something' I want 
'this' to be applied on 'Aclass'
rather than the instance of struct 
'anamespace'. How would I go about that?
Maybe there is a this.parent? I don't 
know... Wouldn't be logical. I was
thinking to make a 
container.iterator.begin() etc, making the interfaces and so
forth isn't a real 
problem. I'd figure making a class out of 'iterator' too
which implements the 
interface and then get's mixed in, but then you don't get
the anamespace thing. 
Adding a member won't work for the 'this' scope... 
 
Oh,
also, I don't explicitly want hackish things, but if you know of a 
way... :P
Maybe I'm totally not seeing something obvious right now... 
Nov 12 2004
parent reply "Walter" <newshound digitalmars.com> writes:
"Joey Peters" <Joey_member pathlink.com> wrote in message
news:cn2m98$mkg$1 digitaldaemon.com...
 Hello.

 I'm updating my STL, and I was getting into problems again (though now
 I
 understand it a lot better). Right now I want to group some parts of the
code
 in the following way:

 #class Aclass {
 #public:







 So I can do

 Aclass a =
 new Aclass;
 a.anamespace.something();

 Maybe that sounds a bit weird but I
 try to be a perfectionist right now ;).
 Anyway, the problem is accessing
 'this'. Like in function 'something' I want
 'this' to be applied on 'Aclass'
 rather than the instance of struct
 'anamespace'. How would I go about that?
 Maybe there is a this.parent? I don't
 know... Wouldn't be logical. I was
 thinking to make a
 container.iterator.begin() etc, making the interfaces and so
 forth isn't a real
 problem. I'd figure making a class out of 'iterator' too
 which implements the
 interface and then get's mixed in, but then you don't get
 the anamespace thing.
 Adding a member won't work for the 'this' scope...
There is no direct way of adding a scoped namespace to a struct or class. But you can do it indirectly by using a mixin template.
Nov 12 2004
parent Joey Peters <Joey_member pathlink.com> writes:
There is no direct way of adding a scoped namespace to a struct or class. 
But you can do it indirectly by using a mixin template. 
Hmm, that just doesn't work as well as I'd want it to work. Maybe zero length argument template specifications could work like namespaces (lame)? Probably not but I can't think of anything. #class Something { #public: #int main() {
Nov 13 2004