next up previous
Next: 2.3.4 組み込み関数の評価 Up: 2.3 eval Previous: 2.3.2 リストの評価

2.3.3 関数定義を取り出す

シンボルに定義されている関数本体を取り出すxlgetfunctionの 部分は以下のようになっています.

#define getfunction(x)   ((x)->n_vdata[1])

/* xlgetfunction - get the functional value of a symbol
              (with check) */
LVAL xlgetfunction(sym)
  LVAL sym;
{
    LVAL val;

    /* look for the functional value of the symbol */
    while ((val = xlxgetfunction(sym)) == s_unbound)
        xlfunbound(sym);

    /* return the value */
    return (val);
}

/* xlxgetfunction - get the functional value of a symbol */
LVAL xlxgetfunction(sym)
  LVAL sym;
{
    register LVAL fp,ep;

    /* check the environment list */
    for (fp = xlfenv; fp; fp = cdr(fp))
        for (ep = car(fp); ep; ep = cdr(ep))
            if (sym == car(car(ep)))
                return (cdr(car(ep)));

    /* return the global value */
    return (getfunction(sym));
}


generated through LaTeX2HTML. M.Inaba 平成18年5月6日