if statments
bnikkel
Posts: 104
in Propeller 1
Can anyone tell me if there are any limitations to how many if statements you can have or nested elseif's? I'm programing in C. thank you
Comments
However if your code is nested many levels deep and is wondering off to the right then it's a sign that you should rethink what you are doing. Your function is probably becoming too big and complex to reason about easily or test easily. If there is a problem with it it's probably too big to post here and ask people to look at.
Clearly you are having a problem in some code you are writing. What?
Usually I chose to use switch after 2-3 nested if's.
Spin has a fairly amount of nested if's possible, but there is a final number, I remember something like 32.
C, as far as I know has no limits there, maybe your compiler might have some.
Enjoy!
Mike
Normally the limit is the address space available to the compiler for holding its parse tree, ie gigabytes on a typical computer these days. You will find the compile-time will become unusable first (unless you switch off optimizations).
For a particular code generator there may be limits due to the binary object format itself.
In general a good compiler has no limits other than resource limits, limits are a hardware thing really, not software.
case X+Y ' test expression
Using OTHER
The optional OTHER component of CASE is similar to the optional ELSE component of an IF structure.
from my code
The indentation thing is the only thing I really don't care for in Spin.
Outside the editor it's so NON-obvious about what's going on, and
simply editing a line of code can radically alter the program structure.
But that's what we have, so enjoy it...