private final EvalResult doDefine ( List < SExpression > subexpressions , Environment environment , ParametricBfgBuilder builder , EvalContext context ) { int nameToBind = subexpressions . get ( 1 ) . getConstantIndex ( ) ; if ( subexpressions . size ( ) == 3 ) { // (define name value-expression) // Binds a name to the value of value-expression Object valueToBind = eval ( subexpressions . get ( 2 ) , environment , builder , context ) . getValue ( ) ; environment . bindName ( nameToBind , valueToBind ) ; } else if ( subexpressions . size ( ) >= 4 ) { // (define procedure-name (arg1 ...) procedure-body) // syntactic sugar equivalent to (define procedure-name (lambda (arg1 ...) procedure-body AmbLambdaValue lambdaValue = makeLambda ( subexpressions . get ( 2 ) , subexpressions . subList ( 3 , subexpressions . size ( ) ) , environment ) ; environment . bindName ( nameToBind , lambdaValue ) ; } return new EvalResult ( ConstantValue . UNDEFINED ) ; }
Evaluates the define special form .