Open JSAbrahams opened 4 years ago
I believe that we can deal with the aforementioned problem by making use of Python's property
built-in function, and generating the following:
class InnerClass
def inner_field: Int := 20
class MyClass
def private inner_class: InnerClass := InnerClass()
@property
def inner_field(self):
return inner_class.inner_field
@inner_field.setter
def inner_field(self, new):
inner_class.inner_field = new
Thus ensuring that when reassign to inner_field
, we do actually assign to the field of the inner class directly.
I.e.
my_class= MyClass()
print(my_class.inner_field) # prints 20
my_class.inner_field = 10
print(my_class.inner_field) # prints 10, because we assigned inner_field directly
Current Issue
Currently, the forward keyword does nothing. Its intended behaviour, however, is to forward methods.
Method forwarding promotes composition (as opposed to inheritance).
High-level description of the feature
The above would be equal to:
Description of potential implementation