Closed JSAbrahams closed 5 years ago
Can use types defined in #65 and the state and context added in #71 . Perhaps it might be better to annotate ASTNodes with types in the type checker, which will make it easier to check the type of identifiers to check whether they're a field/method, or if not, which fields/methods the class has of said identifier.
Mamba has now been changed such that postfix notation is always interpreted as passing an argument to a function for the sake of readability. To access properties we must always use dot notation.
Description of the feature
Calls in the Mamba programming language can either be to a function with no arguments or can be a call to an attribute of an object.
In Python,
a.b
anda.c()
are two different things. In Mamba, We can call functionc
usinga.c
,a.c()
anda c
. During the desugar stage we should either desugar based to a function call or descriptor access based on the type ofa
in this example.Description of potential solution
During the desugar stage there should be some sort of context which should allow us to get the type of an expression, and the accompanying functions. With this list of functions, we can determine whether we wish to access a function or an attribute.
Alternatives considered
It is also possible to check the type of everything again in the desugar stage. However, this seems inefficient and would add a lot of unnecessary code, since this is already done in the type checking stage.
Additional context
We should also think of a system of how to check python files directly. Currently, the type checker will now only check the types, and the functions they contain, in Mamba files, and not Python files.