Re: type checking in EUPHORIA
- Posted by DerekParnell (admin) Sep 17, 2012
- 1217 views
Occasionally, while looking at software written in EUPHORIA I have seen a kind of programming error which a parser can catch.
I agree that the parser should be able to catch more datatype usage errors than it currently does. My take on this is that when the parser can know the datatype of both the source expression and the target of that expression, it should issue a warning if the datatypes are incompatible. This would be a parse-time warning and not a run-time warning. Conversely, if the parser does not absolutely know the datatypes at parse-time, then it should behave as it does now.
This extends beyond enumerated types to also include native types and user-defined types.
To enhance this behaviour, we may have to look at letting the parser know the expected datatype ofa funtion's return value. Currently, from the point of view of the parser, a function always returns an object.
-- example function somefunc(integer a)(sequence) ... return some_seq end function