[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

KCL scoping bug?


Here is all the correspondence on that particular issue from the kcl
mailing list.

 From: vax135!melmac!ilan@ucbvax.Berkeley.EDU
Date: Tue, 3 May 88 10:25:26 edt
To: ilan@ucbvax.Berkeley.EDU, vax135!froggy.ics.utexas.edu!boyer
Subject: KCL scoping bug?


I'm not sure how to post stuff to the KCL board at the moment, so I'm
sending this to you.  If you deem it worthwhile please post it
to the KCL mailing-list.

The following produces a scoping error in the interpreter (June 3, 87) -
the compiler handles the code correctly. (The example is lifted 
directly from CLtL p. 155).


(setq x 'x-dyn z 'z-dyn)Z-DYN

(load "nonsense.l")Loading nonsense.l
Finished loading nonsense.l


  (FOO Z X)
  (LET ((J (FOO K X)) (X (* K K)))
    (FOO X J Z)))

>(nonsense 1 2 3)
(3 2)
(1 2)			;;; <---- SHOULD BE (1 X-DYN)
(1 ((1 2)) Z-DYN)	;;; <---- SHOULD BE (1 ((1 X-DYN)) Z-DYN)
((1 ((1 2)) Z-DYN))	;;; <---- SHOULD BE ((1 ((1 X-DYN)) Z-DYN))

>(compile 'nonsense)End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3

(nonsense 1 2 3)
(3 2)
(1 X-DYN)
(1 ((1 X-DYN)) Z-DYN)
((1 ((1 X-DYN)) Z-DYN))


--Ilan Caron ..!ucbvax!vax135!lcuxlj!ilan

 From: vax135!melmac!ilan@ucbvax.Berkeley.EDU
Date: Tue, 24 May 88 13:41:32 edt
Message-Id: <8805241741.AA29869@vax135.UUCP>
To: ilan@ucbvax.Berkeley.EDU, vax135!cli.com!kcl
Subject: KCL scoping bug?

A couple of weeks ago I posted what seemed to be a KCL interpreter
scoping bug using the example from CLtL p. 155.

Having seen no response to what seems to be a potential source
of major confusion, I'm reposting the bug - this time on a simpler
piece of code.  The interpreter doesn't make a special reference
for Y in spite of the special declaration.

Please note that the bug only manifests itself when interpreted, the
compiler handles the situation correctly.

KCL (June 3, 1987)

Starts dribbling to x (1988/5/25, 2:29:20).

> #'foo

>(setq x 'dyn-x y 'dyn-y z 'dyn-z)

>(foo 'lex-x 'lex-y 'lex-z)
(LEX-Y DYN-Z DYN-Z)			;;; <---- should be (DYN-Y ...)

> (compile 'foo)
; (DEFUN FOO ...) is being compiled.
;; Warning: The variable X is not used.
;; Warning: The variable Y is not used.
;; Warning: The variable Z is not used.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3

>(foo 'lex-x 'lex-y 'lex-z)
(DYN-Y DYN-Z DYN-Z)			;;; <---- this is correct


--ilan caron

Date: Thu, 26 May 88 10:10:26 jst
 From: Taiichi Yuasa <yuasa%tutics.tut.junet@relay.cs.net>
To: kcl@cli.com
Subject: Re: KCL scoping bug?

Here's the story.
I noticed long time ago that there's an inconsistency as you
posted.  However, at that time I did not know which interpretation
is correct.  So, I decided to leave the inconsistency until
someone (x3j13, perhaps) clarifies which is correct.  I still do not
know which is correct.  It's easy to solve the inconsistency.
Is there any general consensus on this matter?
If most people agree that the compiler is correct and the interpreter
is wrong, I'm happy to fix the bug immediately.

-- Taiichi

Received: by CLI.COM (4.0/1); Tue, 31 May 88 12:41:47 CDT
Received: by ucbvax.Berkeley.EDU (5.59/1.28)
	id AA01603; Tue, 31 May 88 09:18:42 PDT
 From: vax135!melmac!ilan@ucbvax.Berkeley.EDU
Date: Tue, 31 May 88 12:13:03 edt
Message-Id: <8805311613.AA03145@vax135.UUCP>
To: vax135!cli.com!kcl
Subject: Re:  KCL scoping bug?

The example and explanation on p. 155 CLtL makes it pretty
clear that the compiler is correct, (i.e. that the special
declaration also applies to references within the initforms
of a LET) - in particular, The Book says: "The reference
to X in the second call to FOO is also a special reference".

For those interested, the relevant nonsensical code is:

  (defun nonsense (k x z)
    (foo z x)
      (j (foo k x))	;;; <--- the problematic reference to X
      (x (* k k))
     (declare (inline foo) (special x z))
     (foo x j z)

--ilan caron