TelluIoT / ThingML

The ThingML modelling language
https://github.com/TelluIoT/ThingML
Apache License 2.0
101 stars 32 forks source link

Cast datatypes to ennumerations #246

Closed ffleurey closed 5 years ago

ffleurey commented 5 years ago

It should be allowed to cast datatype to compatible enumeration. Example:

enumeration IndicatorMode as UInt8 { OFF = 0 SOLID = 1 BLINK_SLOW = 2 BLINK_FAST = 3 }

var myint : UInt8 = 2

var myvalue : IndicatorMode = myint as IndicatorMode

Should be allowed by the checker even if there is the risk that the integer is not within range: with the explicit cast the developer has to make sure it is valid and is taking the responsibility.