FunctionApplication

Overview

Functions are created by using the Defun statement, followed by the Name, Lambda List of parameters, and finally the Body. The Body of the function may consist of numerous expressions that require evaluating. When Defun is used, the compiler calls the Function Parser code and passes in the Lambda List of parameters. The Function Parser separates the Lambda List into "bindings" that contain the pertinent information for each variable/expression in the Lambda List. All of the "bindings" are grouped into a larger list which is then stored in an anonymous Lambda until a user applies the function and the compiler retrieves the list and hands it to the Function Letification code.

The Function Letification code is where the list of "bindings" is parsed out and made into a Let* application for use at run-time. Each "binding" has the parameter name symbolized and then bound to the provided argument or the init-form if no argument was provided. Simultaneously, the unbound symbols are also placed into a list that will be bound to the function name before the entire Let* is returned to the compiler to run. The rest and keywords functions create forms that will be evaluated at run-time.

Implementation

All functions were written in Lisp code. The existing function parser was rewritten to take advantage of the new compiler and to make it more streamlined. Each parameter in the Lambda List is placed into a "binding" along with its scope, type, usage, init-form, and allocation. Each complete "binding" is then added to the list of "bindings" as the parser goes through the parameter types in specified order: required, optional, rest, and keywords. Once all parameters have been bound and added to the list, the complete list is returned to the compiler where it is stored into a Lambda until the function is applied by a user.

When a user applies the function, the compiler retrieves the list of "bindings" and calls letify-function-application and passes the list of "bindings" and the function list (ie '(foo 1 2 3)). Each function checks the "binding" to see if the usage is correct. If the usage is of the functions type then the function changes the parameter name into a symbol and binds it to the passed in argument, if available, or the init-form in the "binding". The unbound symbol is also added to a list of symbols representing the paramters of the function which will be bound to the function name in the Let*. Once the Let* is completed it is passed back to the compiler for use at run-time.

Discussions

Links to Blog issues

Current Status of FunctionApplication

Status:

Release Level:

Open bug count:

Test Suites

Links to JUnit results

-- JerryBoetje - 12 Jul 2003

Topic revision: r3 - 2009-02-11 - 01:23:06 - MeganLusher
 
Home
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback