Welcome to %s forums

BrainModular Users Forum

Login Register

Scripting - Differences between Procedures and Functions

I need help on a Patch
Post Reply
sephult
Member
Posts: 1144
Contact:

Unread post by sephult » 23 Sep 2016, 12:51

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
"Every act of creation is first an act of destruction." -Picasso

ahonoe
Member
Posts: 161
Location: Toronto
Contact:

Unread post by ahonoe » 26 Sep 2016, 23:58

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.
Regards,

Scott

User avatar
oli_lab
Member
Posts: 1263
Location: Brittany, France
Contact:

Unread post by oli_lab » 27 Sep 2016, 08:25

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 .
http://oli-lab.org

Win11 Ryzen9/32GB RAM - RME MADIFACE - SSL alpha link 4-16 - OSC capable interfaces

follow OLI_LAB adventures on Mastodon
@olivar_premier@mastodon.social

shawnb
Member
Posts: 190
Location: San Francisco
Contact:

Unread post by shawnb » 27 Sep 2016, 15:06

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.
Address the process rather than the outcome. Then, the outcome becomes more likely. - Fripp

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests