Re: type checking in EUPHORIA
- Posted by SDPringle Sep 17, 2012
- 1262 views
The major drawback that I can see here is that I think it would prevent you from directly passing a value as returned from a function (even if the function correctly returns the correct thing). Or if you stored the enum into a sequence, and then pulled it out later and passed it to a function.
Matt
If an argument to a function or a comparison consists of more than a single token the checking is skipped. This single token must be a constant, literal or a variable. This is one thing I didn't make clear as something I was not thinking of changing.
If you have two enumerated types: 'boolean' and 'weekday'. Suppose the boolean type consists of 'false'(=0) and 'true'(=1) constants. Then assigning a weekday with the value 'false' using the token false, will provoke a warning. However if you assign the same value which is not some enumerated type, like '0' there is no warning.
weekday wd = Sunday -- okay! sequence s = {Monday, Friday} -- type literal information is lost inside this sequence. wd = s[1] -- No check... more than one token. s = { 0, 3 } wd = s[1] -- okay! No check... more than one token. wd = false -- warning wd = platform() -- no check... wd = 0 -- no warning.... should there be?
Shawn Pringle