You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Working with goto-math is dangerous
Describe the solution you'd like
An assert expression applied at compile-time, and will raise an error if the expression is false. This expression is only functionally useful for Line-Labels.
For example:
t = 0
f = 1
mode_check>
:flight = f and :mode
:turret = t and :mode
GOTO mode_check+(not :mode)
ASSERT mode_swap = mode_check + 1 // Compiles successfully
mode_swap>
f = not f
t = not t
:FcuRotationalPitch = 0
:FcuRotationalYaw = 0
:FcuRotationalRoll = 0
:ModeColor = t + 3 * f
:Mode = 1
goto mode_check
t = 0
f = 1
mode_check>
:flight = f and :mode
:turret = t and :mode
GOTO mode_check+(not :mode)
ASSERT mode_swap = mode_check + 1 // Fails
$
mode_swap>
f = not f
t = not t
:FcuRotationalPitch = 0
:FcuRotationalYaw = 0
:FcuRotationalRoll = 0
:ModeColor = t + 3 * f
:Mode = 1
goto mode_check
Describe alternatives you've considered
Using names multiplied by truthiness is always correct, but more verbose
Using gotos is always an excellent way to shoot yourself in the foot. These things are error-prone, unreadable and bad style in general.
Instead of improving goto-math I would rather like to completely get rid of user-crafted goto-math.
I am thinking of if-statements beeing automatically compiled to goto-math wen reasonable, or just a justom syntax-feature for jump-tables ( for example #102 ).
That would prevent stupid mistakes from the start, make code readable and help people that are not even aware of how goto-math can be used as an alternative to ifs.
So, I had some time to think about this.
There will be no such assertions.
Goto-math is dangerous and if the user insists on using it, he will have to accept the risk.
#102 would make implementing jump-tables reasonably safe, which is the main use-case for goto-stuff like this. I think thats good enough.
Is your feature request related to a problem? Please describe.
Working with goto-math is dangerous
Describe the solution you'd like
An assert expression applied at compile-time, and will raise an error if the expression is false. This expression is only functionally useful for Line-Labels.
For example:
Describe alternatives you've considered
Using names multiplied by truthiness is always correct, but more verbose
Additional context
#107
The text was updated successfully, but these errors were encountered: