Re: type checking in EUPHORIA

new topic     » goto parent     » topic index » view thread      » older message » newer message
mattlewis said...

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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu