SMath Studio Forum
»
SMath Studio
»
Bugs & Problems
»
evaluation inside for and while loops
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,650 Location: Italy Was thanked: 1338 time(s) in 878 post(s)
|
Hi, I've found this strange behavior when you evaluate instructions inside for and while loops; IMHO the direct evaluation ( = , -> ) inside loops could be (simply?) inhibited without any losses regards, w3b5urf3r Edited by user 18 September 2012 01:36:14(UTC)
| Reason: Not specified File Attachment(s): Davide Carpi attached the following image(s): |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
1 user thanked Davide Carpi for this useful post.
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 15/04/2012(UTC) Posts: 1,988 Was thanked: 1127 time(s) in 723 post(s)
|
Hi, Originally Posted by: w3b5urf3r_reloaded Hi,
I've found this strange behavior when you evalutate instructions inside for and while loops;
IMHO the direct evalutation ( = , -> ) inside loops could be (simply?) inhibited without any losses
regards,
w3b5urf3r I guess that symbolic or numeric evaluation is already inhibited inside any expressions. Wherever you submit = or ->, the operator is put to the end of the complete expression, in this case at the end of the for or while loop or the if statement. In contrast to this, the assignment operator can be used in whatever substructures. The odd result of for or while loops may be due to that these functions do not provide any return value. Attempt to assign the result of the control structure to a variable fails (syntax error). Perhaps the evaluation operators call a method that the control structure objects just do not provide. In UPN, if you want to use the result of some operation, you have to leave it on the stack. I guess that is where the error message comes from. a:while(k<0,2+2)The if statement returns the value of the corresponding branch and does neither fail to display it nor to provide it for assignment. a:if(0<1,2+2,3+3)results in a=4@#Back to your proposal of inhibiting evaluation of control structures, an alternative might be to provide meaningful return values. The line operator returns the value of the last statement (what if that is a for loop ? Loops might return the number of executions, for a while-loop that might occasionally save a separate counter, in a for loop this would be a bit redundant. Best regards, Martin |
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Bugs & Problems
»
evaluation inside for and while loops
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.