Shop OBEX P1 Docs P2 Docs Learn Events
Is this a bug on Spin and/or the Propeller Tool? — Parallax Forums

Is this a bug on Spin and/or the Propeller Tool?

TinkersALotTinkersALot Posts: 535
edited 2013-04-12 21:47 in Propeller 1
I think that values in a case repeating is compiled (I think the code crashes, but it seems the construct is invalid and should not compile?)

try this:
case _some_var
  1:
      code and stuff
  2:
      other code and stuff
  1:
      huh?

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-04-12 21:43
    No, that will compile. CASE constructs are examined in order, and the first to meet the conditions is executed. Don't forget that the CASE antecedents can also be variables and expressions, so their values may not be known at compile time.

    -Phil
  • TinkersALotTinkersALot Posts: 535
    edited 2013-04-12 21:47
    No, that will compile. CASE constructs are examined in order, and the first to meet the conditions is executed. Don't forget that the CASE antecedents can also be variables and expressions, so their values may not be known at compile time.

    -Phil

    Yes it does compile, but I had some cogs that were crashing, and I saw this "anti-pattern" in the code and it looks very suspicious to me. I understand what you are saying about non-constants being evaluated though. I will keep burning in the code without the repeating condition values and see what happens.
Sign In or Register to comment.