Skip to content

Latest commit

 

History

History
46 lines (34 loc) · 1.22 KB

ImplementationNotes.md

File metadata and controls

46 lines (34 loc) · 1.22 KB

Implementation Notes

This project is based on the following:

Functions that take open ended lists as arguments

When a function takes a list of arguments such as ObjectUnionOf:

ObjectUnionOf := 'ObjectUnionOf' '(' ClassExpression ClassExpression { ClassExpression } ')' 

which says that ObjectUnionOf can have 2 or more ClassExpressions, the literal mapping of this to the funowl Python idiom would be:

@dataclass
class ObjectUnionOf(FunOwlBase):
    classExpressions: List["ClassExpression"]

    ...

This turns out to be a less than optimal in the python idiom, as ObjectUnionOf( a:Man a:Woman ) would have to be constructed using a list:

u = ObjectUnionOf([A.Man, A.Woman])

In this case, we override the constructor:

@dataclass
class ObjectUnionOf(FunOwlBase):
    classExpressions: List["ClassExpression"]

    def __init__(self, *classExpression: "ClassExpression") -> None:
        self.classExpressions = list(classExpression)
        super().__init__()

Resulting in the more natural:

u = ObjectUnionOf(A.Man, A.Woman)