Changeset 4069


Ignore:
Timestamp:
09/26/03 14:21:22 (19 years ago)
Author:
piso
Message:

_let(): added try/finally to make sure dynamic environment is restored
correctly in all cases.

File:
1 edited

Legend:

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

    r4066 r4069  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Primitives.java,v 1.440 2003-09-26 01:10:00 piso Exp $
     5 * $Id: Primitives.java,v 1.441 2003-09-26 14:21:22 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    28142814
    28152815    private static final LispObject _let(LispObject args, Environment env,
    2816         boolean sequential) throws ConditionThrowable
     2816                                         boolean sequential)
     2817        throws ConditionThrowable
    28172818    {
    28182819        LispObject varList = checkList(args.car());
     
    28212822        if (varList != NIL) {
    28222823            Environment oldDynEnv = thread.getDynamicEnvironment();
    2823             Environment ext = new Environment(env);
    2824             Environment evalEnv = sequential ? ext : env;
    2825             for (int i = varList.length(); i-- > 0;) {
    2826                 LispObject obj = varList.car();
    2827                 varList = varList.cdr();
    2828                 if (obj instanceof Cons) {
    2829                     bind(checkSymbol(obj.car()),
    2830                          eval(obj.cadr(), evalEnv, thread),
    2831                          ext);
    2832                 } else
    2833                     bind(checkSymbol(obj), NIL, ext);
    2834             }
    2835             LispObject body = args.cdr();
    2836             while (body != NIL) {
    2837                 result = eval(body.car(), ext, thread);
    2838                 body = body.cdr();
    2839             }
    2840             thread.setDynamicEnvironment(oldDynEnv);
     2824            try {
     2825                Environment ext = new Environment(env);
     2826                Environment evalEnv = sequential ? ext : env;
     2827                for (int i = varList.length(); i-- > 0;) {
     2828                    LispObject obj = varList.car();
     2829                    varList = varList.cdr();
     2830                    if (obj instanceof Cons) {
     2831                        bind(checkSymbol(obj.car()),
     2832                             eval(obj.cadr(), evalEnv, thread),
     2833                             ext);
     2834                    } else
     2835                        bind(checkSymbol(obj), NIL, ext);
     2836                }
     2837                LispObject body = args.cdr();
     2838                while (body != NIL) {
     2839                    result = eval(body.car(), ext, thread);
     2840                    body = body.cdr();
     2841                }
     2842            }
     2843            finally {
     2844                thread.setDynamicEnvironment(oldDynEnv);
     2845            }
    28412846        } else {
    28422847            LispObject body = args.cdr();
Note: See TracChangeset for help on using the changeset viewer.