// // Lambda.java : Lisp 関数(Lambda)クラス定義 // // This is a part of miolisp sourcefile // Copyright (C) 1998 Nishiyama, Naoki / Mio software lab. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // import java.util.* ; public final class Lambda extends Macro { Lambda(Environment ev,Object a,Object b) throws Exception { super(ev,a,b) ; // Local 辞書のクローンを作成。辞書 Table もコピー ec = ev.getLocalVars() ; } public Object eval(Object a,Environment e) throws Exception { Object o = Evalutil.evalall(minargs,maxargs,a,e) ; // closure 辞書を加えて、env のクローンを作成 // ただし、辞書の Table 実体は同じもの。 Environment env = e.getNewDic(ec) ; if (arg.length > 0) { Hashtable h = bindlist(arg.length,arg,o) ; env.addNewDic(h) ; // 引数を束縛 } return Evalutil.evprogn(body,env) ; } }