OPLMantras

Inspired by J. Canning's poems/mantras for teaching ideas in 91.101 Computing I; e.g.:

What is a string?
“A string is a pointer to a character
followed by a series of characters
ending in a null byte.”

I propose the following mantras for OPL.


Define

What does define do?
“Define creates a binding
from a symbol to an object
in an environment.”


Evaluation

What are the normal Scheme evaluation rules?
“To evaluate an expression,
evaluate all of its sub-expressions,
then apply the procedure that is the value of the left-most sub-expression
(the operator)
to the the arguments that are the values of the other sub-expressions
(the operands).”


Closure

What is a closure?
“A closure is a first-class function
with free variables that are bound
in the lexical environment.”

With thanks to Wikipedia.


Environments and Frames

What is a frame?
“A frame is a place where bindings are made from symbols to objects.”
What does define do?
“Define creates a binding
from a symbol to an object
in a frame.”
What is an environment?
“An environment is a series of frames.”


Procedure Application

How do I apply a procedure?
“To apply a procedure,
create a new frame and in it bind the parameters' symbols to their associated values,
link that frame back to the frame from which the procedure was created,
and evaluate the body of the procedure from this new frame.”


Let and Lambda

What is let?
let is syntactic sugar for lambda,
which creates a new frame with bindings for the symbols created in the header of the let,
and evaluates by body of the let in the context of this new frame.”
(let ( <var> <exp> )) <body> )
((lambda ( <var> ) <body> ) <exp> )