[comp.lang.scheme] Scoops bug

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (04/29/91)

The Scoops function MAKE-INSTANCE gets muddled when the *value* of
one instvar is EQ? to the *name* of another.  Example:
	(define-class buggy
	    (instvars a b)
	    (options inittable-variables))
	(compile-class buggy)
	(define-method (example ->list) ()
	    (list 'a a 'b b))
	(send (make-instance 'a 'b 'b 'c) ->list)
yields the answer
	(A B B B)
instead of the correct answer
	(A B B C)

This error exists both in TI PC Scheme 3.x and the version of scoops
I picked up from Oz's repository.  The problem is that the initialiser
function is looking for instvars among the actual parameters by using
memq, something like this:
	(let ( ...
		(instvar (cond ((memq 'instvar args) => cadr)
			       (else --use the default--)))
		...) ...)
It should instead use oddmemq, where
	(define (oddmemq obj list)
	    (cond ((not (pair? list)) #f)
		  ((not (pair? (cdr list))) #f)
		  ((eq? obj (car list)) list)
		  (else (oddmemq obj (cddr list)) )))


-- 
Bad things happen periodically, and they're going to happen to somebody.
Why not you?					-- John Allen Paulos.