zakirullin / cognitive-load

🧠 Cognitive Load is what matters
Creative Commons Attribution 4.0 International
3.75k stars 77 forks source link

Wrong example in [Complex conditionals] #28

Open khanhicetea opened 1 week ago

khanhicetea commented 1 week ago

Hi @zakirullin , your article is good :)

Btw, this example is some kind wrong as code (though it looks the same in domain-space)

image

The above code acts like a logic gate of 3 ANDs of 3 expressions (mean it can include function calls) The below (solution) acts like a logic gate of 3 ANDS of 3 variables store of excecuted expression results

zakirullin commented 1 day ago

Hi @khanhicetea, thanks for the feedback!

This is both an artificial language and an artificial example. Also, I didn't provide EBNF for the language, maybe its grammar doesn't have function calls in condition :) But you're right, in the second case all function calls (if there are any) would be executed regardless of previous conditions, which in some cases may cause issues.

I am not sure if we should overload the reader with all sorts details or tricky edge-cases while conveying this general idea.