This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: GSOC | Extending Common Lisp support


Hi Charles,

On Jun 5, 2012, at 2:33 PM, Charles Turner wrote:

Hi Jamison,

I noticed the same behavior in Scheme earlier today (this is a bug
right? Not some arcane difference between Lisp1/2), but hadn't noticed
the type data point. I'll be investigating that today.

Yup, it's a bug. The procedure binding within the let should not be overwriting the top-level binding.

Here's another potential clue: if you use fluid-let, then the behavior
is correct.

#|kawa:1|# (define (myfun) 'myfun1)
#|kawa:2|# (define x ::procedure myfun)
#|kawa:3|# myfun
#<procedure myfun>
#|kawa:4|# x
#<procedure myfun>
#|kawa:5|# (fluid-let ((x (lambda () 'inner))) (display x) (display myfun))
#<procedure /dev/stdin:5> #<procedure myfun>
#|kawa:6|# x
#<procedure myfun>
#|kawa:7|# (let ((x (lambda () 'inner2))) (display x) (display myfun))
#<procedure x> #<procedure x>
#|kawa:8|# (myfun)
inner2


Notice that within the body of the let on line 7, the binding for myfun
has already changed.

So it would appear that there's something about how bindings are
handled within a LetExp (but not FluidLetExp) that isn't quite right.

Somewhat tangentially, all these lexical.pushes when you load an
average Scheme file, all the core forms appear to get new RefExp's
every time you evaluate a new form, i.e., in the REPL, when you type
(LET ...) followed by (LET ...), you see the same mass of lexical
pushes/RefExp creations in both evaluations. Surely these things can
be cached? Wouldn't that be an enormous saving? I accidentally ran
make with all my println's, and was amazed at just how many times
"core" forms were being looked up/wrapped in RefExps. Am I
misinterpreting something?

You might be right about the pushes, it does seem like a lot. I'm pretty sure each RefExp is supposed to uniquely belong to a particular location in the source code, so if you have two LET blocks you should get two "let" RefExps. But it does seem like each of them is reloading and pushing the same stuff from std_syntax, and doing it twice at that.

One concern I would have is that the cache could grow stale - what
happens if we execute a form which has a side effect changing the meaning
of LET?


It's also worth noting that even with all of the pushing and popping,
the compiler is still pretty fast. Would a cache (plus whatever mechanism
is required to ensure the cached data is still valid) be faster? Perhaps,
but significantly so? Premature optimization and all that.


Thanks,
Charles.


-Jamie

--
Jamison Hope
The PTR Group
www.theptrgroup.com




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]