bug in if()

bug in if() - immediate evaluation behind line() - Poruke

#1 Objavljeno: 26. 3. 2022. 08:49:18
Martin_B

Martin_B

22 svidjanja u 84 postova.

Grupa: User

Hi!

Is this a bug in if()?

It turns to a real problem e.g. when used in a case like shown in the example.

bug_if.png
bug_if.sm (15,42 KiB) preuzeto 1586 put(ova).
#2 Objavljeno: 26. 3. 2022. 21:18:52
overlord

overlord

601 svidjanja u 1.382 postova.

Grupa: Moderator

Wrote

Hi!

Is this a bug in if()?

It turns to a real problem e.g. when used in a case like shown in the example


Yes, it is a bug.

if() function doesn't like plotting, solvers, custom functions as in your example, etc.

You have to use cases() for that kind of usages.

Regards
#3 Objavljeno: 29. 3. 2022. 06:08:28
Davide Carpi

Davide Carpi

1.444 svidjanja u 2.936 postova.

Grupa: Moderator

Just to clarify, this is not a fault in the specific function, it works this way because the current architecture of the core doesn't allows a different implementation (thus can't be simply fixed with a change in the function itself).

if(...) currently requires the condition argument to be defined on evaluation, otherwise an error is thrown; this makes the if/else instructions sealed from further evaluations of the preprocessor.

As opposite cases(...) doesn't throw errors on simbolic conditions, but this makes instructions evaluable (thus you shouldn't add any definition in the case() arguments).



If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
1 korisnika je svidelo ovu objavu
sergio 29. 3. 2022. 10:15:00
  • Novi postovi
  • Nema novih postova