Next: 4.3.2 list
Up: 4.3 Car, Cdr
Previous: 4.3 Car, Cdr
xconsは次のようにconsをただ呼び出すだけです.
LVAL xcons()
{
LVAL arg1,arg2;
/* get the two arguments */
arg1 = xlgetarg();
arg2 = xlgetarg();
xllastarg();
/* construct a new list element */
return (cons(arg1,arg2));
}
consは,xldmem.cの中に定義されており,
/* cons - construct a new cons node */
LVAL cons(x,y)
LVAL x,y;
{
LVAL nnode;
/* get a free node */
if ((nnode = fnodes) == NIL) {
xlstkcheck(2);
xlprotect(x);
xlprotect(y);
findmem();
if ((nnode = fnodes) == NIL)
xlabort("insufficient node space");
xlpop();
xlpop();
}
/* unlink the node from the free list */
fnodes = cdr(nnode);
--nfree;
/* initialize the new node */
nnode->n_type = CONS;
rplaca(nnode,x);
rplacd(nnode,y);
/* return the new node */
return (nnode);
}
となっています.
xlprotect,xlpopは,xlisp.hに,
#define xlprotect(n) {*--xlstack = &n;}
#define xlpop() {++xlstack;}
というぐあいに定義されています.
generated through LaTeX2HTML. M.Inaba 平成18年5月6日