Hi,
I have a class, that adds a mixin.
I would like to hide a few of the mixin public members/methods so as to only use them internally, but have them be invisible (private) to the outside consumer. (the hiding happens in the class, doesn't change the mixin itself)
Is this possible for mixins?
a way to accomplish this is to instantiate objects inside the class, and then create methods that mimic them -- manually exposing whichever I want,
but that's more work than I would like.
I think a support for setting access rights for specific methods in the added mixin would be an ideal solution.
please your comments
Forums
RFC for suggestion: setting access rights to added mixins
4 posts
• Page 1 of 1
RFC for suggestion: setting access rights to added mixins
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
Truth, Compassion, Forbearance is Good.
- kobi7
- Posts: 82
- Location: Israel
Re: RFC for suggestion: setting access rights to added mixin
"is protected"
This almost works:
I had to comment out the last line because "two" is a protected member and cannot be seen by class P. Cobra correctly reports that error.
However, there is a bug in the code generation which prevents the above program from running. I should be able to fix later today.
This almost works:
mixin A
def one as int
return 1
def two as int is protected
return 2
class B adds A
def foo
trace .one
trace .two
class P
def main
b = B()
b.foo
b.one
# b.two
I had to comment out the last line because "two" is a protected member and cannot be seen by class P. Cobra correctly reports that error.
However, there is a bug in the code generation which prevents the above program from running. I should be able to fix later today.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: RFC for suggestion: setting access rights to added mixin
This is fixed now. Members can be protected and private. They are injected as is, into the class (or struct), so they become protected and private members of what they are added to.
There is currently no way to make a member private to the mixin. We can leave that as is or try to address it.
As you use mixins, keep sharing whatever issues you run into.
There is currently no way to make a member private to the mixin. We can leave that as is or try to address it.
As you use mixins, keep sharing whatever issues you run into.
- Charles
- Posts: 2515
- Location: Los Angeles, CA
Re: RFC for suggestion: setting access rights to added mixin
cool thanks!
I'll open another thread if I find more.
I'll open another thread if I find more.
Falun Dafa is Good.
Truth, Compassion, Forbearance is Good.
Truth, Compassion, Forbearance is Good.
- kobi7
- Posts: 82
- Location: Israel
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 41 guests