Investigating the use of data in Dennis revealed several instances of the following basic pattern.
class Base:
attr: int
def protocol_method(self) -> ???:
raise NotImplementedError
data Concrete from Base:
def protocol_method(self) -> ???:
...
class EasyWay(Concrete, enum.Enum):
...
# Inherits Concrete's implementation of protocol_method
class HardWay(Base, enum.Enum):
...
def protocol_method(self) -> ???:
return typing.cast(Base, self.value).protocol_method()
# Inherits Base's non-implementation of protocol_method, and must therefore explicitly forward it to the method on self.value
It'd be nice to have some means of forwarding the value automatically.
I'm leaning towards a method decorator that detects when it's being accessed on Enum subclasses.
I don't know if this is within the scope of ADT or not. I may attempt to create it within its own library and see if it can stand on its own.
Investigating the use of
data
in Dennis revealed several instances of the following basic pattern.It'd be nice to have some means of forwarding the value automatically.
I'm leaning towards a method decorator that detects when it's being accessed on Enum subclasses.
I don't know if this is within the scope of ADT or not. I may attempt to create it within its own library and see if it can stand on its own.