define

 

 

Description

The define special form permits the user to declare a new variable and initialize it to an Lambda. The Lambda may receive zero or more arguments, and its body may have zero or more expressions. In this form, define always returns the value to which name is initialized (Note: this value will always be an Lambda object).

If a list of argument names is specified (name arg...), at runtime, the Lambda's arguments are bound to the actual arguments respectively. Passing an incorrect number of arguments results in an error message. (See the lambda special form).

If an indefinite list of argument names is specified (name arg...) , at runtime, the Lambda's arguments are bound to the actual definite arguments respectively. Passing too few arguments results in an error message. If too many arguments are passed, the remaining arguments can only be accessed via the argCount and argFetch functions. (See the lambda special form).

The keyword faces: (var...) declares the interfaces feature Structure of the Lambda. The features are specified as lists, faces: ((english true) (french false)), the listed feature is initialized to the value specified.

The keyword vars: (var...) declares the temporary variables of the Lambda. The variables are specified as a list vars: (X Y...). If any one of the variables is specified as a list, vars: ((X 0) Y...), the listed variable is initialized to the constant value specified. (The local variable X is initialized to the constant 0). Unlike the setq or define special forms, the vars special form always evaluates the initialization value as a constant.

The keyword pvars: (var...) declares the persistent variables of the Lambda. The variables are specified as a list pvars: (W Q...). If any one of the variables is specified as a list, pvars: ((X 0) Y...), the listed variable is initialized to the constant value specified. (The variable X is initialized to the constant 0). Unlike the setq or define special forms, the pvars special form always evaluates the initialization value as a constant. <![endif]>.

The keyword cvars: (var...) declares the persistent class variables of the Lambda. The variables are specified as a list cvars:(W Q...). If any one of the variables is specified as a list, cvars: ((X 0) Y...), the listed variable is initialized to the constant value specified. (The variable X is initialized to the constant 0). Unlike the setq or define special forms, the cvars special form always evaluates the initialization value as a constant.

The keyword rvars: (var...) declares the register variables of the Lambda. The variables are specified as a list rvars:(W Q...). If any one of the variables is specified as a list, regs: ((X Integer) Y...), the listed variable is initialized to the type value specified (Integer, Number, CharPointer, ShortPointer, JumpPointer, IntPointer, or NumPointer). The variable X is initialized to the data type Integer (up to fifty register variables are allowed). Unlike the cvars or pvars special forms, the regs special form always evaluates the initialization value as a data type.

The keyword doomed: declares that the Lambda is to be evaluated, by the garbage collector, when the Lambda is doomed. The Lambda's EvalWhenDoomed property is set to true. The Lambda is always evaluated, by the garbage collector, with no arguments.

The body of the Lambda is a sequence of Lisp expressions {exp}. At runtime, each of the expressions is evaluated, in the extended environment, from left to right. The Lambda returns the value of the final expression in the sequence.

When to use

The define function defines the name of an Lambda, its arguments, and the statements that comprise the Lambda.

 

Syntax

(define (name arg...) faces: (var...) vars: (var...) pvars: (var...) cvars: (var...) regs: (vars...) exp...)



Name Description AIS Types
(arg...) Optional Argument. Argument list for the Lambda. ---
faces:(var...) Optional Argument. If present, must be followed by a interfaces feature list. Symbol
vars:(var...) Optional Argument. If present, must be followed by a local variable list.Symbol
pvars:(var...) Optional Argument. If present, must be followed by a persistent variable list.Symbol
cvars:(var...) Optional Argument. If present, must be followed by a persistent class variable list.Symbol
regs:(var...) Optional Argument. If present, must be followed by a register variable list (up to fifty register variables are allowed).Symbol
exp... The Lisp statements that forms the Lambdas---


Returns:

An Lambda that will be assigned the name {child}.

 

Examples

Here are a number of links to Lambda coding examples which contain this instruction in various use cases.

 

Argument Types

Here are the links to the data types of the function arguments.

Lambda Symbol

Here are also a number of links to functions having arguments with any of these data types.

++(Symbol) +=(Symbol) /=(Symbol) *=(Symbol)
--(Symbol) -=(Symbol) addMethod(BitVector) addMethod(Boolean)
addMethod(Brick) addMethod(Character) addMethod(CpxVector) addMethod(Date)
addMethod(Dictionary) addMethod(Directory) addMethod(FltVector) addMethod(Function)
addMethod(IntVector) addMethod(List) addMethod(Matrix) addMethod(NumMatrix)
addMethod(NumVector) addMethod(Number) addMethod(ObjVector) addMethod(ObjectRepository)
addMethod(Pair) addMethod(PcodeVector) addMethod(ShortVector) addMethod(String)
addMethod(Structure) addMethod(Symbol) addMethod(Vector) addMethod(Void)
append(BitVector) append(Complex) append(CpxVector) append(FltVector)
append(IntVector) append(Matrix) append(NumMatrix) append(NumVector)
append(ObjVector) append(Pair) append(ShortVector) append(String)
append(Structure) append(Symbol) append(Vector) apply(BitVector)
apply(CpxVector) apply(FltVector) apply(IntVector) apply(Matrix)
apply(NumMatrix) apply(NumVector) apply(Pair) apply(ShortVector)
apply(Structure) apply(Vector) argCount(Lambda) argFetch(Lambda)
attachLibrarian(ObjectRepository) balance(Lambda) binaryInsert(CpxVector) binaryInsert(FltVector)
binaryInsert(IntVector) binaryInsert(Matrix) binaryInsert(NumMatrix) binaryInsert(NumVector)
binaryInsert(ShortVector) binaryInsert(Structure) binaryInsert(Vector) binarySearch(CpxVector)
binarySearch(Dictionary) binarySearch(FltVector) binarySearch(IntVector) binarySearch(Matrix)
binarySearch(NumMatrix) binarySearch(NumVector) binarySearch(ObjVector) binarySearch(ShortVector)
binarySearch(Structure) binarySearch(Vector) boolean(Boolean) callcc(Lambda)
cdr(BitVector) cdr(Brick) cdr(CpxVector) cdr(Dictionary)
cdr(Directory) cdr(FltVector) cdr(IntVector) cdr(List)
cdr(Matrix) cdr(NumMatrix) cdr(NumVector) cdr(ObjVector)
cdr(ShortVector) cdr(Structure) cdr(Vector) character(Character)
compareEQ(BitVector) compareEQ(Boolean) compareEQ(Brick) compareEQ(Character)
compareEQ(Complex) compareEQ(CpxVector) compareEQ(Date) compareEQ(Dictionary)
compareEQ(Directory) compareEQ(FltVector) compareEQ(Function) compareEQ(IntVector)
compareEQ(Lambda) compareEQ(List) compareEQ(Matrix) compareEQ(NumMatrix)
compareEQ(NumVector) compareEQ(Number) compareEQ(ObjVector) compareEQ(ObjectRepository)
compareEQ(Pair) compareEQ(ShortVector) compareEQ(String) compareEQ(Structure)
compareEQ(Symbol) compareEQ(Vector) compareEQ(Void) compareGE(BitVector)
compareGE(Boolean) compareGE(Brick) compareGE(Character) compareGE(Complex)
compareGE(CpxVector) compareGE(Date) compareGE(Dictionary) compareGE(Directory)
compareGE(Function) compareGE(IntVector) compareGE(Lambda) compareGE(List)
compareGE(Matrix) compareGE(NumMatrix) compareGE(Number) compareGE(ObjVector)
compareGE(ObjectRepository) compareGE(Pair) compareGE(ShortVector) compareGE(String)
compareGE(Structure) compareGE(Symbol) compareGE(Vector) compareGE(Void)
compareGT(BitVector) compareGT(Boolean) compareGT(Brick) compareGT(Character)
compareGT(Complex) compareGT(CpxVector) compareGT(Date) compareGT(Dictionary)
compareGT(Directory) compareGT(Function) compareGT(IntVector) compareGT(Lambda)
compareGT(List) compareGT(Matrix) compareGT(NumMatrix) compareGT(NumVector)
compareGT(Number) compareGT(ObjVector) compareGT(ObjectRepository) compareGT(Pair)
compareGT(ShortVector) compareGT(String) compareGT(Structure) compareGT(Symbol)
compareGT(Vector) compareGT(Void) compareLE(BitVector) compareLE(Boolean)
compareLE(Brick) compareLE(Character) compareLE(Complex) compareLE(CpxVector)
compareLE(Date) compareLE(Dictionary) compareLE(Directory) compareLE(FltVector)
compareLE(Function) compareLE(IntVector) compareLE(Lambda) compareLE(List)
compareLE(Matrix) compareLE(NumMatrix) compareLE(NumVector) compareLE(Number)
compareLE(ObjVector) compareLE(ObjectRepository) compareLE(Pair) compareLE(ShortVector)
compareLE(String) compareLE(Structure) compareLE(Symbol) compareLE(Vector)
compareLE(Void) compareLT(BitVector) compareLT(Boolean) compareLT(Brick)
compareLT(Character) compareLT(Complex) compareLT(CpxVector) compareLT(Date)
compareLT(Dictionary) compareLT(Directory) compareLT(FltVector) compareLT(Function)
compareLT(IntVector) compareLT(Lambda) compareLT(List) compareLT(Matrix)
compareLT(NumMatrix) compareLT(NumVector) compareLT(Number) compareLT(ObjVector)
compareLT(ObjectRepository) compareLT(Pair) compareLT(ShortVector) compareLT(String)
compareLT(Structure) compareLT(Symbol) compareLT(Vector) compareLT(Void)
compareNE(BitVector) compareNE(Boolean) compareNE(Brick) compareNE(Character)
compareNE(Complex) compareNE(CpxVector) compareNE(Date) compareNE(Dictionary)
compareNE(Directory) compareNE(FltVector) compareNE(Function) compareNE(IntVector)
compareNE(Lambda) compareNE(List) compareNE(Matrix) compareNE(NumMatrix)
compareNE(NumVector) compareNE(Number) compareNE(ObjVector) compareNE(ObjectRepository)
compareNE(Pair) compareNE(ShortVector) compareNE(String) compareNE(Structure)
compareNE(Symbol) compareNE(Vector) compareNE(Void) compare(BitVector)
compare(Boolean) compare(Brick) compare(Character) compare(Complex)
compare(CpxVector) compare(Date) compare(Dictionary) compare(Directory)
compare(FltVector) compare(Function) compare(IntVector) compare(Lambda)
compare(List) compare(Matrix) compare(NumMatrix) compare(NumVector)
compare(Number) compare(ObjVector) compare(ObjectRepository) compare(Pair)
compare(ShortVector) compare(String) compare(Structure) compare(Symbol)
compare(Vector) compare(Void) comparison(BitVector) comparison(Boolean)
comparison(Brick) comparison(Character) comparison(Complex) comparison(Date)
comparison(Dictionary) comparison(Directory) comparison(FltVector) comparison(Function)
comparison(IntVector) comparison(List) comparison(Matrix) comparison(NumMatrix)
comparison(NumVector) comparison(Number) comparison(ObjVector) comparison(ObjectRepository)
comparison(Pair) comparison(ShortVector) comparison(String) comparison(Structure)
comparison(Symbol) comparison(Vector) comparison(Void) compile(Lambda)
compile(List) compress(ByteVector) cons(Pair) copy(BitVector)
copy(Brick) copy(CpxVector) copy(Dictionary) copy(Directory)
copy(FltVector) copy(IntVector) copy(Lambda) copy(List)
copy(Matrix) copy(NumMatrix) copy(NumVector) copy(ObjVector)
copy(Pair) copy(PcodeVector) copy(ShortVector) copy(Structure)
copy(Vector) count(Dictionary) count(Directory) count(List)
count(Matrix) count(NumMatrix) count(Pair) count(Structure)
count(Vector) debugBrowsableProcs(Context) debugBrowsableProcs(Lambda) debug(Context)
debug(Lambda) defchild(Lambda) define(macro)(Lambda) define(Lambda)
defmacro(Lambda) defmethod(BitVector) defmethod(Boolean) defmethod(Brick)
defmethod(Character) defmethod(Date) defmethod(Dictionary) defmethod(Directory)
defmethod(FltVector) defmethod(Function) defmethod(IntVector) defmethod(List)
defmethod(Matrix) defmethod(NumMatrix) defmethod(NumVector) defmethod(Number)
defmethod(ObjectRepository) defmethod(Pair) defmethod(ShortVector) defmethod(String)
defmethod(Structure) defmethod(Symbol) defmethod(Vector) defmethod(Void)
deforphan(Lambda) defriend(Lambda) defun(Lambda) delete(Dictionary)
delete(Directory) delete(FltVector) delete(IntVector) delete(List)
delete(Matrix) delete(NumMatrix) delete(NumVector) delete(ObjVector)
delete(ObjectRepository) delete(Pair) delete(ShortVector) delete(Structure)
delete(Vector) detachLibrarian(ObjectRepository) disassemble(Context) disassemble(Lambda)
display(ByteVector) display(FileIO) downcase(String) downcase(Symbol)
encode(ByteVector) evalInSyncLocalContext(Context) eval(Lambda) eval(List)
exportTab(Lambda) exportTab(ObjectRepository) gc(Context) getGlobalValue(Context)
getGlobalValue(Symbol) getSymbolTable(Context) getSymbolTable(Symbol) globalBinding(Context)
globalBinding(Lambda) importTab(Lambda) importTab(ObjectRepository) insert(Dictionary)
insert(Directory) insert(FltVector) insert(IntVector) insert(Matrix)
insert(NumMatrix) insert(NumVector) insert(ObjVector) insert(ShortVector)
insert(Structure) insert(Vector) inside(BitVector) inside(Dictionary)
inside(Directory) inside(IntVector) inside(List) inside(Matrix)
inside(NumMatrix) inside(NumVector) inside(ShortVector) inside(Structure)
inside(Vector) inspect(Context) inspect(Lambda) inspect(ObjectRepository)
integer(Integer) isAtom(BitVector) isAtom(Brick) isAtom(Dictionary)
isAtom(Directory) isAtom(FltVector) isAtom(IntVector) isAtom(List)
isAtom(Matrix) isAtom(NumMatrix) isAtom(NumVector) isAtom(ObjVector)
isAtom(Pair) isAtom(PcodeVector) isAtom(ShortVector) isAtom(Structure)
isAtom(Vector) isBitVector(BitVector) isBoolean(Boolean) isByteVector(ByteVector)
isCharAlphabetic(ByteVector) isCharAlphabetic(String) isCharAlphabetic(Symbol) isCharAlphanumeric(ByteVector)
isCharAlphanumeric(String) isCharAlphanumeric(Symbol) isCharLowercase(ByteVector) isCharLowercase(String)
isCharLowercase(Symbol) isCharName(ByteVector) isCharName(String) isCharName(Symbol)
isCharNumeric(ByteVector) isCharNumeric(String) isCharNumeric(Symbol) isCharUppercase(ByteVector)
isCharUppercase(String) isCharUppercase(Symbol) isCharWhitespace(ByteVector) isCharWhitespace(String)
isCharWhitespace(Symbol) isChar(String) isCharacter(Character) isComplex(Complex)
isDate(Date) isDictionary(Dictionary) isDirectory(Directory) isEqual(BitVector)
isEqual(Boolean) isEqual(Brick) isEqual(Character) isEqual(Complex)
isEqual(Date) isEqual(Dictionary) isEqual(Directory) isEqual(FltVector)
isEqual(Function) isEqual(IntVector) isEqual(List) isEqual(Matrix)
isEqual(NumMatrix) isEqual(NumVector) isEqual(Number) isEqual(ObjVector)
isEqual(Pair) isEqual(ShortVector) isEqual(String) isEqual(Structure)
isEqual(Vector) isEqual(Void) isError(Error) isFloatVector(FltVector)
isIdentical(BitVector) isIdentical(Boolean) isIdentical(Brick) isIdentical(Character)
isIdentical(Complex) isIdentical(Date) isIdentical(Dictionary) isIdentical(Directory)
isIdentical(Error) isIdentical(FltVector) isIdentical(Function) isIdentical(IntVector)
isIdentical(List) isIdentical(Matrix) isIdentical(NumMatrix) isIdentical(NumVector)
isIdentical(Number) isIdentical(ObjVector) isIdentical(ObjectRepository) isIdentical(Pair)
isIdentical(PcodeVector) isIdentical(ShortVector) isIdentical(Structure) isIdentical(Vector)
isIdentical(Void) isInside(BitVector) isInside(Dictionary) isInside(Directory)
isInside(IntVector) isInside(List) isInside(Matrix) isInside(NumMatrix)
isInside(NumVector) isInside(ObjVector) isInside(Pair) isInside(ShortVector)
isInside(Structure) isInside(Vector) isIntegerVector(IntVector) isInteger(Integer)
isMatrix(Matrix) isMember(BitVector) isMember(Dictionary) isMember(Directory)
isMember(IntVector) isMember(List) isMember(Matrix) isMember(NumMatrix)
isMember(NumVector) isMember(ObjVector) isMember(Pair) isMember(ShortVector)
isMember(Structure) isMember(Vector) isMoney(Number) isNumberMatrix(NumMatrix)
isNumberVector(NumVector) isNumber(Number) isObjectVector(ObjVector) isObject(BitVector)
isObject(Brick) isObject(ByteVector) isObject(Dictionary) isObject(Directory)
isObject(FltVector) isObject(IntVector) isObject(List) isObject(Matrix)
isObject(NumMatrix) isObject(NumVector) isObject(ObjVector) isObject(Pair)
isObject(PcodeVector) isObject(ShortVector) isObject(String) isObject(Structure)
isObject(Symbol) isObject(Vector) isPair(List) isPair(Pair)
isPcodeVector(PcodeVector) isString(String) isStructure(Structure) isSymbol(Symbol)
isText(String) isType(BitVector) isType(Boolean) isType(Brick)
isType(Character) isType(Complex) isType(Date) isType(Dictionary)
isType(Directory) isType(FltVector) isType(Function) isType(IntVector)
isType(Matrix) isType(NumMatrix) isType(NumVector) isType(Number)
isType(ObjVector) isType(ObjectRepository) isType(Pair) isType(ShortVector)
isType(String) isType(Structure) isType(Symbol) isType(Vector)
isType(Void) isVector(Vector) lambda(Lambda) length(BitVector)
length(Brick) length(Dictionary) length(Directory) length(FltVector)
length(IntVector) length(List) length(Matrix) length(NumMatrix)
length(NumVector) length(ObjVector) length(ObjectRepository) length(Pair)
length(PcodeVector) length(ShortVector) length(String) length(Structure)
length(Symbol) length(Vector) lisp(Lambda) lisp(List)
list(List) macroReplace(String) makeLambda(Lambda) makeQuotedList(List)
makeQuotedSymbol(Symbol) member(BitVector) member(Dictionary) member(Directory)
member(IntVector) member(List) member(Matrix) member(NumMatrix)
member(NumVector) member(ObjVector) member(ShortVector) member(Structure)
member(Vector) methodsOf(BitVector) methodsOf(Boolean) methodsOf(Brick)
methodsOf(Character) methodsOf(Complex) methodsOf(Date) methodsOf(Dictionary)
methodsOf(Directory) methodsOf(FltVector) methodsOf(Function) methodsOf(IntVector)
methodsOf(List) methodsOf(Matrix) methodsOf(NumMatrix) methodsOf(NumVector)
methodsOf(Number) methodsOf(ObjVector) methodsOf(ObjectRepository) methodsOf(Pair)
methodsOf(PcodeVector) methodsOf(ShortVector) methodsOf(String) methodsOf(Structure)
methodsOf(Symbol) methodsOf(Vector) methodsOf(Void) money(Number)
myself(Lambda) new(BitVector) new(Brick) new(ByteVector)
new(CpxVector) new(Dictionary) new(Directory) new(FltVector)
new(IntVector) new(Lambda) new(Matrix) new(NumMatrix)
new(NumVector) new(ObjVector) new(ObjectRepository) new(PcodeVector)
new(ShortVector) new(String) new(Structure) new(Symbol)
new(Vector) number(Number) onError(Error) onError(Lambda)
openLog(FileIO) openLog(String) pair(Pair) parse(String)
proplist(Symbol) proprecord(Symbol) putprop(Symbol) refLibrarian(ObjectRepository)
ref(BitVector) ref(Boolean) ref(Brick) ref(Character)
ref(Complex) ref(Date) ref(Dictionary) ref(Directory)
ref(FltVector) ref(Function) ref(IntVector) ref(Lambda)
ref(List) ref(Matrix) ref(NumMatrix) ref(NumVector)
ref(Number) ref(ObjVector) ref(ObjectRepository) ref(PcodeVector)
ref(ShortVector) ref(String) ref(Structure) ref(Symbol)
ref(Vector) ref(Void) remProp(Symbol) remove(BitVector)
remove(Dictionary) remove(Directory) remove(IntVector) remove(Matrix)
remove(NumMatrix) remove(NumVector) remove(ObjVector) remove(ShortVector)
remove(Structure) remove(Vector) rename(ObjectRepository) saveObject(ByteVector)
saveObject(Integer) saveRepository(ObjectRepository) send(BitVector) send(Boolean)
send(Brick) send(Character) send(CpxVector) send(Date)
send(Dictionary) send(Directory) send(FltVector) send(Function)
send(IntVector) send(Lambda) send(List) send(Matrix)
send(NumMatrix) send(NumVector) send(Number) send(ObjectRepository)
send(Pair) send(ShortVector) send(String) send(Structure)
send(Symbol) send(Vector) send(Void) setCar(List)
setCar(Pair) setCdr(BitVector) setCdr(Brick) setCdr(Dictionary)
setCdr(Directory) setCdr(FltVector) setCdr(IntVector) setCdr(List)
setCdr(Matrix) setCdr(NumMatrix) setCdr(NumVector) setCdr(ObjVector)
setCdr(Pair) setCdr(ShortVector) setCdr(Structure) setCdr(Vector)
setLastCdr(BitVector) setLastCdr(FltVector) setLastCdr(IntVector) setLastCdr(List)
setLastCdr(Matrix) setLastCdr(NumMatrix) setLastCdr(NumVector) setLastCdr(ObjVector)
setLastCdr(Structure) setLastCdr(Vector) set(ObjectRepository) setf(ObjectRepository)
setq(BitVector) setq(Boolean) setq(Brick) setq(Character)
setq(Date) setq(Dictionary) setq(Directory) setq(FltVector)
setq(IntVector) setq(Lambda) setq(List) setq(Matrix)
setq(NumVector) setq(Number) setq(ObjVector) setq(ObjectRepository)
setq(PcodeVector) setq(ShortVector) setq(String) setq(Structure)
setq(Symbol) setq(Vector) setq(Void) sizeof(BitVector)
sizeof(Boolean) sizeof(Brick) sizeof(ByteVector) sizeof(Character)
sizeof(Complex) sizeof(Date) sizeof(Dictionary) sizeof(Directory)
sizeof(FltVector) sizeof(Function) sizeof(IntVector) sizeof(List)
sizeof(Matrix) sizeof(NumMatrix) sizeof(NumVector) sizeof(Number)
sizeof(ObjVector) sizeof(ObjectRepository) sizeof(Pair) sizeof(PcodeVector)
sizeof(ShortVector) sizeof(String) sizeof(Structure) sizeof(Symbol)
sizeof(Vector) sizeof(Void) string(Complex) string(String)
svmRegression(Vector) symbol(Symbol) type(BitVector) type(Boolean)
type(Brick) type(ByteVector) type(Character) type(Complex)
type(Date) type(Dictionary) type(Directory) type(FltVector)
type(Function) type(IntVector) type(Lambda) type(Matrix)
type(NumMatrix) type(NumVector) type(Number) type(ObjVector)
type(ObjectRepository) type(Pair) type(PcodeVector) type(ShortVector)
type(String) type(Structure) type(Symbol) type(Vector)
type(Void) uniqueInsert(FltVector) uniqueInsert(IntVector) uniqueInsert(Matrix)
uniqueInsert(NumMatrix) uniqueInsert(NumVector) uniqueInsert(ObjVector) uniqueInsert(ShortVector)
uniqueInsert(Structure) uniqueInsert(Vector) vectorFill(BitVector) vectorFill(FltVector)
vectorFill(IntVector) vectorFill(Matrix) vectorFill(NumMatrix) vectorFill(NumVector)
vectorFill(ObjVector) vectorFill(ShortVector) vectorFill(Vector) writeln(ByteVector)
writeln(String) writeln(Text)

How do I contact the AIS team?

You can always talk with the AIS at aiserver.sourceforge.net.