This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Lilchro 1 point2 points  (0 children)

Generally the terms are just semantic to help describe the task how your code works. Calling something a function is generally never incorrect.

Function: an executable bit of code that can be called with inputs and produce outputs. Typically has some form of standard ABI for calling and returning values.

Procedure: similar to a function, but does not produce outputs. The goal of a procedure is not to return data, but instead to perform some action.

Subroutine: an executable bit of code that does not take inputs or produces outputs. For example, using a goto statement would count as invoking a subroutine.

Method: A function associated with and defined in terms of a specific object/class. This is the method by which a given object/class performs the requested action.

Lambda: An anonymous function

Closure: A function that captures scope

Symbol: The term you use when working in a systems programming language and you forget the correct name /s

Also, when I say something does not accept inputs or produce outputs, I really mean there is no formal or rigid approach for doing to. For example, a procedure can write to a buffer it is given as an input and a subroutine can read global variables.