general programming patterns, closure pattern, clam pattern, c lambda abstraction, arsapi patterns, Programmierung pur


General Programming Patterns Derived From ARS

Very powerful general programming patterns can be derived from ARS, an abstraction from the Lambda Calculus.

Closure Pattern

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:

  • it can be stored in memory,
  • it can be passed as an argument to a function and
  • it may be returned as a value from a function.
The slight difference between a closure and an object in OOP is the following:
  • A closure is essentially a function that can be called, but may have all kinds of data and procedures encapsulated in it.
  • An object is essentially a data item with all kinds of data and procedures encapsulated in it. One of its procedures (normally called methods) may be 'apply', allowing to apply the object to a set of arguments, which essentially is the same as calling a function.

CLAM Pattern

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.

List Pattern

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.

Set Pattern

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.

See also:ARSAPI.

Home
domain access counter
(c) Copyright 2005 lambda-bound.com