Changeset 4400


Ignore:
Timestamp:
10/16/03 00:32:26 (19 years ago)
Author:
piso
Message:

%DEFUN: support environment argument.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/Primitives.java

    r4398 r4400  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.475 2003-10-15 20:40:37 piso Exp $
     5 * $Id: Primitives.java,v 1.476 2003-10-16 00:32:26 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    12711271
    12721272    // ### %defun
    1273     // %defun name arglist body => name
    1274     private static final Primitive3 _DEFUN =
    1275         new Primitive3("%defun", PACKAGE_SYS, false)
    1276     {
    1277         public LispObject execute(LispObject first, LispObject second,
    1278                                   LispObject third)
    1279             throws ConditionThrowable
    1280         {
     1273    // %defun name arglist body environment => name
     1274    private static final Primitive _DEFUN = new Primitive("%defun", PACKAGE_SYS, false)
     1275    {
     1276        public LispObject execute(LispObject[] args) throws ConditionThrowable
     1277        {
     1278            if (args.length < 3 || args.length > 4)
     1279                throw new ConditionThrowable(new WrongNumberOfArgumentsException(this));
     1280            LispObject first = args[0];
     1281            LispObject second = args[1];
     1282            LispObject third = args[2];
     1283            Environment env;
     1284            if (args.length == 4 && args[3] != NIL)
     1285                env = checkEnvironment(args[3]);
     1286            else
     1287                env = new Environment();
    12811288            if (first instanceof Symbol) {
    12821289                Symbol symbol = checkSymbol(first);
     
    12971304                body = new Cons(body, NIL);
    12981305                Closure closure = new Closure(symbol.getName(), arglist, body,
    1299                                               new Environment());
     1306                                              env);
    13001307                closure.setArglist(arglist);
    13011308                symbol.setSymbolFunction(closure);
     
    13141321                body = new Cons(Symbol.BLOCK, body);
    13151322                body = new Cons(body, NIL);
    1316                 Closure closure = new Closure(arglist, body, new Environment());
     1323                Closure closure = new Closure(arglist, body, env);
    13171324                closure.setArglist(arglist);
    13181325                put(symbol, PACKAGE_SYS.intern("SETF-FUNCTION"), closure);
Note: See TracChangeset for help on using the changeset viewer.