Changeset 11767


Ignore:
Timestamp:
04/19/09 20:10:56 (14 years ago)
Author:
ehuelsmann
Message:
  • Stop declaring symbols SPECIAL mid-environment:

usually, this pollutes the environment, as you'd want
to create a new one to store the special binding in.

  • Fix the single ANSI test failure this causes

(SYMBOL-MACROLET.8) by always creating a new
environment and processing the declarations in
SYMBOL-MACROLET.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/SpecialOperators.java

    r11754 r11767  
    210210        LispObject varList = checkList(args.car());
    211211        final LispThread thread = LispThread.currentThread();
    212         if (varList != NIL)
    213           {
    214             SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
    215             try
    216               {
    217                 Environment ext = new Environment(env);
    218                 // Declare our free specials, this will correctly raise
    219                 LispObject body = ext.processDeclarations(args.cdr());
    220 
    221                 for (int i = varList.length(); i-- > 0;)
    222                   {
    223                     LispObject obj = varList.car();
    224                     varList = varList.cdr();
    225                     if (obj instanceof Cons && obj.length() == 2)
    226                       {
    227                         Symbol symbol = checkSymbol(obj.car());
    228                         if (symbol.isSpecialVariable()
    229                              || ext.isDeclaredSpecial(symbol))
    230                           {
    231                             return error(new ProgramError(
     212        SpecialBinding lastSpecialBinding = thread.lastSpecialBinding;
     213        Environment ext = new Environment(env);
     214        try
     215         {
     216             // Declare our free specials, this will correctly raise
     217             LispObject body = ext.processDeclarations(args.cdr());
     218
     219             for (int i = varList.length(); i-- > 0;)
     220               {
     221                 LispObject obj = varList.car();
     222                 varList = varList.cdr();
     223                 if (obj instanceof Cons && obj.length() == 2)
     224                   {
     225                     Symbol symbol = checkSymbol(obj.car());
     226                     if (symbol.isSpecialVariable()
     227                         || ext.isDeclaredSpecial(symbol))
     228                       {
     229                          return error(new ProgramError(
    232230                              "Attempt to bind the special variable " +
    233231                              symbol.writeToString() +
    234232                              " with SYMBOL-MACROLET."));
    235                           }
    236                         bindArg(null, symbol, new SymbolMacro(obj.cadr()), ext, thread);
    237                       }
    238                     else
    239                       {
    240                         return error(new ProgramError(
    241                           "Malformed symbol-expansion pair in SYMBOL-MACROLET: " +
    242                           obj.writeToString()));
    243                       }
    244                   }
    245                 return progn(body, ext, thread);
    246               }
    247             finally
    248               {
     233                       }
     234                     bindArg(null, symbol, new SymbolMacro(obj.cadr()), ext, thread);
     235                   }
     236                 else
     237                   {
     238                     return error(new ProgramError(
     239                       "Malformed symbol-expansion pair in SYMBOL-MACROLET: " +
     240                       obj.writeToString()));
     241                   }
     242                }
     243             return progn(body, ext, thread);
     244              }
     245        finally
     246            {
    249247                thread.lastSpecialBinding = lastSpecialBinding;
    250               }
    251           }
    252         else
    253           {
    254             return progn(args.cdr(), env, thread);
    255           }
     248            }
    256249      }
    257250    };
     
    448441        throws ConditionThrowable
    449442      {
    450         while (args != NIL)
    451           {
    452             LispObject decl = args.car();
    453             args = args.cdr();
    454             if (decl instanceof Cons && decl.car() == Symbol.SPECIAL)
    455               {
    456                 LispObject vars = decl.cdr();
    457                 while (vars != NIL)
    458                   {
    459                     Symbol var = checkSymbol(vars.car());
    460                     env.declareSpecial(var);
    461                     vars = vars.cdr();
    462                   }
    463               }
    464           }
    465443        return NIL;
    466444      }
Note: See TracChangeset for help on using the changeset viewer.