function or procedure

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
duxbuz
 
Posts: 2
Joined: Tue May 20, 2014 5:48 am

function or procedure

Post by duxbuz »

Hi

Just looking at http://www.ladyada.net/learn/arduino/lesson4.html
I wondered whether a procedure is a function and why procedure is the language used in the lessons?

Is there a big reason or would the two be considered interchangeable?


Thanks

User avatar
adafruit_support_bill
 
Posts: 88087
Joined: Sat Feb 07, 2009 10:11 am

Re: function or procedure

Post by adafruit_support_bill »

In practice, these terms are often used interchangeably, along with 'method', 'subroutine', 'subprogram' etc.
In some programming languages functions and procedures have different syntax and semantics. But C/C++ is not so picky.

Mathematically speaking, a function returns a value based on the input. It should have no side effects.
A procedure is a series of operations. It may or may not return a value and/or have side-effects.

duxbuz
 
Posts: 2
Joined: Tue May 20, 2014 5:48 am

Re: function or procedure

Post by duxbuz »

I agree with what you say.

I would probably use the term function in the examples. It seems more appropriate to me.

Thanks

Locked
Please be positive and constructive with your questions and comments.

Return to “For Educators”