eq? 関数 はアドレスを比較する

比較関数を見直してたら間違い発見。
eq? はアドレス比較しなくてはいけないのか!

http://www.shido.info/lisp/scheme5.html

eq?
2つの引数をとり、2つのオブジェクトのアドレスを比較する。アドレスが等しければ真、 そうでなければ偽。

    @Override
    public Sexp eval(IPair cons, Map<AtomSymbol, Sexp> env) throws FunctionException {
        super.checkArgmunet(cons, 2);

        Sexp[] list = cons.getCdr().getList();
        Sexp sexpA = MyLisp.apply(list[0], env);
        Sexp sexpB = MyLisp.apply(list[1], env);
        //誤り; return Atom.newAtom(sexpA.toString().equals(sexpB.toString()));
        return Atom.newAtom(sexpA == sexpB);
    }
MyLisp > (define str "hello")
[eval] (define str "hello")
>> STR
MyLisp > (eq? str str)
[eval] (eq? str str)
>> #t
MyLisp > (eq? "hello" "hello")
[eval] (eq? "hello" "hello")
>> #f
MyLisp > (eq? 1 1)
[eval] (eq? 1 1)
>> #f

問題ないようです。

https://github.com/moremagic/MyLisp