Nested function call: Difference between revisions
(Created page with "A convention used in many programming languages (python, javascript, C, liquidsoap) When you see: foo(bar(baz())) In fact what happens is: * baz() gets c...") |
No edit summary |
||
Line 4: | Line 4: | ||
foo(bar(baz())) | foo(bar(baz())) | ||
In fact what happens is: | In fact what happens is: |
Revision as of 06:58, 15 May 2020
A convention used in many programming languages (python, javascript, C, liquidsoap)
When you see:
foo(bar(baz()))
In fact what happens is:
- baz() gets called, and it's output * send as input to:
- bar( * ) which gets call, and it's output ** sent as input to:
- foo ( ** )
Using temporary variables, the whole process could also be written:
x = baz() y = bar(x) z = foo(y)
But since it's more compact, programmers tend to write:
result = foo(bar(baz()))
Which often is more readable since you use less variable names, thus reducing cognitive overload.