digitalmars.D - interface/template/class public/private issue
- Regan Heath (33/33) Jun 22 2004 Can someone point out my error here?
- Sean Kelly (4/5) Jun 22 2004 mixin works the same way as import, so 'private' delineates stuff that's...
- Regan Heath (28/33) Jun 22 2004 Ahh. ok, but doesn't that mean I have to split my mixin into 2 mixins in...
- Regan Heath (27/59) Jun 23 2004 In fact.. I cannot seem to work out how to mixin something giving it
Can someone point out my error here? --[test2.d]-- module test2; interface A { public: void fn(); private: void doStuff(); } template B() { public: void fn() { doStuff(); } private: ulong length = 0; } class C : A { mixin B; public: private: void doStuff() { length = 10; } } void main() { } D:\D\src\build>dmd test2.d test2.d(19): class C B!().length is private What does the mixin do to the public/private state/scope? Regan. -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jun 22 2004
In article <opr90s39am5a2sq9 digitalmars.com>, Regan Heath says...What does the mixin do to the public/private state/scope?mixin works the same way as import, so 'private' delineates stuff that's not accessible outside the mixin itself. Sean
Jun 22 2004
On Wed, 23 Jun 2004 00:02:17 +0000 (UTC), Sean Kelly <sean f4.ca> wrote:In article <opr90s39am5a2sq9 digitalmars.com>, Regan Heath says...Ahh. ok, but doesn't that mean I have to split my mixin into 2 mixins in order to mix some of it as private and some as public i.e. template FooPrivate { int a; } template FooPublic { int b; } class Bar { private: mixin FooPrivate; public: mixin FooPublic; } instead of simply being able to go: template Foo { private: int a; public: int b; } class Bar { mixin Foo; } Regan -- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/What does the mixin do to the public/private state/scope?mixin works the same way as import, so 'private' delineates stuff that's not accessible outside the mixin itself.
Jun 22 2004
In fact.. I cannot seem to work out how to mixin something giving it 'private' access. eg. template md() { uint[4] context = [ 0,1,2,3 ]; } struct md5 { mixin md; void foo() { context[0] = 1; } } void main() { md5 m; m.context[1] = 3; } I want the foo fn in md5 to be able to access context, but main not to be able to. I tried every permutation of adding public private to various places, no luck. Help! Regan. On Wed, 23 Jun 2004 13:25:41 +1200, Regan Heath <regan netwin.co.nz> wrote:On Wed, 23 Jun 2004 00:02:17 +0000 (UTC), Sean Kelly <sean f4.ca> wrote:-- Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/In article <opr90s39am5a2sq9 digitalmars.com>, Regan Heath says...Ahh. ok, but doesn't that mean I have to split my mixin into 2 mixins in order to mix some of it as private and some as public i.e. template FooPrivate { int a; } template FooPublic { int b; } class Bar { private: mixin FooPrivate; public: mixin FooPublic; } instead of simply being able to go: template Foo { private: int a; public: int b; } class Bar { mixin Foo; } ReganWhat does the mixin do to the public/private state/scope?mixin works the same way as import, so 'private' delineates stuff that's not accessible outside the mixin itself.
Jun 23 2004