[MIT-Scheme-users] queries related to list operations
From:
Amey Karkare
Subject:
[MIT-Scheme-users] queries related to list operations
Date:
Fri, 24 Feb 2006 14:05:23 +0530
Hi,
I am trying to understand memory management of mit-scheme. I have
understood a bit about how car/cdr/cons work (through Prim_car /
Prim_cdr / Prim_cons counterparts in C). However I am having some
difficulties in the following:
(1) When I say, at interpreter prompt:
(define lst (cons 1 (cons 2 '()))
I can see the Prim_cons function getting called, and memory being
allocated for list '(1 2). But I cannot find out what happens when I say -
(define lst '(1 2))
How and where is the memory for list '(1 2) is allocated?
(2) When I call
(car '(1 2 3 4))
I see a call to Prim_car. However, I am unable to understand why
the call to function "list?->length" in "runtime/list.scm" which
invokes car/cdr does NOT result in Prim_car / Prim_cdr being
called? Also, if I load "runtime/list.scm" in scheme interpreter
and then call "length" - now the calls to Prim_car/Prim_cdr are
there.
Please explain or give me some suggestions where to look for the
answers to above questions.
Thanks and regards,
Amey karkare
-- Amey Karkare, CSE Research Scholar, IIT Bombay.