-
Notifications
You must be signed in to change notification settings - Fork 0
Routine
Ben Christel edited this page Feb 5, 2023
·
10 revisions
I use the following terms to refer to callable units of code:
- Routine
- A section of code that can be Called.
-
Procedure
- A routine that has Effects or Accesses process-external state (e.g. makes SystemCalls).
- If a procedure does not Access any FreeVariables, its ProcedureClosures are Values.
-
Method
- A routine that takes and returns Values and does not make SystemCalls, but Accesses FreeVariables.
-
Function
- A Nilpotent, ReferentiallyTransparent routine that operates on Values and does not refer to any state.
-
Constructor
- A Nilpotent, Non-ReferentiallyTransparent routine that returns a new Object, and does not refer to any State.
-
Instrument
- A routine that technically makes SystemCalls, but none that feed back into the logic of the program. For example, an Instrument might Log to a file or measure performance.
The types of routines vary in their Capabilities.
Note that all of these terms refer to static/source-code entities. A Closure is a runtime instantiation of a routine in which FreeVariables of the routine are looked up in the LexicalScope that was in effect at the time and place of the closure's creation. We can thus speak of ProcedureClosures, MethodClosures, and FunctionClosures. There can be many different closures in a process that originate from the same routine.
The ways in which a routine can interact with State are:
- making SystemCalls, a.k.a. having Effects.
- Accessing ProcessGlobalState.
- receiving Objects as parameters.
- returning Objects.
- accessing LocalState in its enclosing lexical scope.