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

Re: objects, and evalhook query

    (define (make-array contents dims) ...

    ...but I don't seem to get any chance to initialize the "instance
    variables" contents and dims; there is no equivalent to the NEW
    method in Smalltalk.  Or have I just missed it?

Maybe I missed something in your letter.  You pass in "contents" and
"dims" as arguments.  Why, then, would you want to initialize them?
Contrariwise, if you are going to initialize them, why pass them 
in as arguments?

Assuming that an array can be created given the dimensions,
what you want is probably something like this:

(define (make-array dims)
  (let ((contents (make-vector (apply * dims)) ))
    (object nil
	((array? self) t)
	((aref self subs) (vref contents (...
	(((setter aref) self subs new) 
	    (set (vref contents (...

Note that the object is closed in an environment in which both 
"contents" and "dims" are bound.  The difference is that one
is initialized and one is defined by the user.

                --- Jonathan