Creating Records
Most commonly, records are created as a program runs, rather than being declared at compile time.
In Lisp, the function (cons x y ) always allocates a new record, then assigns its car and cdr pointers to be the specified values x and y.
| Scheme | (set! p (cons 3 lst)) |
| Pascal | new(p); |
| p^.car := 3; | |
| p^.cdr := lst; | |
| C++ | cons *p = new cons; |
| p->car = 3; | |
| p->cdr = lst; | |
| Java | Cons p = new Cons(3, lst); |
Contents    Page-10    Prev    Next    Page+10    Index