Page 1 of 1

Posted: 23 Sep 2016, 12:51
by sephult
Hello!

I was curious of the differences of creating multiple called procedures vs. functions
being used. This might be a more Nay/Senso directed question but I thought was
very information...or quite possibly another coder could chime in with more
information regarding the usage of such.

I understand that the function results in a value, but a procedure does not......but,

I was also wondering if there was more processing involved with calling a procedure vs.
using a function? Obviously the code in the middle matters, but just in general...does a
procedure involve any more processing power than a function does?

-s

Posted: 26 Sep 2016, 23:58
by ahonoe
I am curious about the same thing. None of the (little) reading I have done on Pascal tells me anything more than that a function returns a value whereas a procedure does not.

Posted: 27 Sep 2016, 08:25
by oli_lab
My guess woukd Be that à procedure need To have thé variables déclarés on the script level and the function does not . So there is less memory uses with function .

Posted: 27 Sep 2016, 15:06
by shawnb
In native Pascal, the difference is negligible. The only differences are the pushes/pops associated with functions putting the returned values on the stack and the calling code retrieving them. A minor CPU cost.

Without functions, you are stuck working far more with global variables. For a list of dangers associated with that, consult any Cobol programmer. Functions add readability and protection of values, overall adding stability.

I do not know if the HH engine adds any additional overhead to functions. Unlikely.