General Programming Patterns Derived From ARS
Very powerful general programming patterns can be derived from ARS, an abstraction from the Lambda Calculus.
The most fundamental of the general programming patterns derived from ARS is the closure pattern. A closure is an encapsulation of a lambda abstraction with its total environment. This environment consists of all the names of abstractions that this lambda abstraction has access to. Access to names in a lambda abstraction is controlled by the so called 'lexical scope'. Lexical scope can also be described as the context of a lambda abstraction in the program text. A detailed explanation is given in the book Programmierung pur.
A closure is a first class object, which means that it can be treated like any data item:
The CLAM pattern is just an implementation of the general closure pattern in C. The pattern is describe in detail in the book: Programmierung pur.
The acronym CLAM stands for: C Lambda Abstraction. A CLAM is therefore an implementation of a lambda abstraction as defined in ARS in the programming language C.
Because a CLAM is an encapsulation of data and procedures (the lambda abstraction with its total environment) it can be compared to an object in object oriented technology. The easy to apply CLAM pattern derived from ARS provides a C programmer with all the whistles and bells functional programming and object oriented programming are justly so proud of.
The list pattern provides many functions like
constructors, selectors and mutators that allow
building lists, retrieving elements from lists,
sorting lists, inserting elements, modifying lists
and combining lists.
The set pattern corresponds more or less to the list pattern with some additional functions providing set operations on lists.
Higher Order Function Pattern
The higher order function pattern handles functions that take functions as arguments and/or return functions as values. For example the 'compose' function takes two functions as arguments and creates a new function that is returned as value.
Message Passing Pattern
The message passing pattern implements the static object model like the one normally used in Java, C++ and other OOP languages. In this model objects are created and communicated with via messages.
Meta Object Protocol Pattern
The meta object protocol pattern implements a dynamic object model. In a this model methods can be dynamically created, modified and deleted.