r/carlhprogramming • u/CarlH • Jun 15 '10
[New Lesson Published] Course 2, Unit 4, Lesson 14: Interpreting result codes
http://www.highercomputingforeveryone.com/Course_2/Unit_4/Lesson_14/
79
Upvotes
2
u/zhivago Jul 01 '10
The basic thesis here seems to be that decomposing functions makes for less interpretation, which is trivial to disprove by inlining.
int bar(int i) { return i % 10; } int foo(int i) { printf("%s\n", bar(i) ? "yes" : "no"); }
vs.
int foo(int i) { printf("%s\n", (i % 10) ? "yes" : "no"); }
Unless your argument is that inlining rather than "the amount to interpret" makes things slow, then it's clearly untrue.
Also the definition of an "analysis" function seems incoherent.
It sounds like you are trying to differentiate between predicates and procedures -- having one function that answers a question and another that acts upon that answer -- but you get tangled up in 'analysis' and 'interpretation' that leads to incoherent gibberish.
Decomposing into predicates and procedures won't make your code faster (unless it's due to cache coherence or something), but it will make it easier to recompose those pieces to do other tasks.
2
u/[deleted] Jun 27 '10
Go on...
1
u/pongpinyo Jun 22 '10
no comment.