Changeset 5061


Ignore:
Timestamp:
12/10/03 21:35:47 (18 years ago)
Author:
asimon
Message:

Added coerceToFunctional

File:
1 edited

Legend:

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

    r4985 r5061  
    33 *
    44 * Copyright (C) 2002-2003 Peter Graves
    5  * $Id: Lisp.java,v 1.184 2003-12-06 01:26:57 piso Exp $
     5 * $Id: Lisp.java,v 1.185 2003-12-10 21:35:47 asimon Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    956956    }
    957957
     958    public static final Functional coerceToFunctional(LispObject obj)
     959        throws ConditionThrowable
     960    {
     961        if (obj instanceof Functional)
     962            return (Functional) obj;
     963        if (obj instanceof Symbol) {
     964            LispObject fun = obj.getSymbolFunction();
     965            if (fun instanceof Functional)
     966                return (Functional) fun;
     967        } else if (obj instanceof Cons && obj.car() == Symbol.LAMBDA)
     968            return new Closure(obj.cadr(), obj.cddr(), new Environment());
     969        throw new ConditionThrowable(new UndefinedFunction(obj));
     970    }
     971
    958972    // Returns package or throws exception.
    959973    public static final Package coerceToPackage(LispObject obj)
Note: See TracChangeset for help on using the changeset viewer.