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

Re: Sample implementation



Lars Thomas Hansen <lth@xxxxxxxxxxx> writes:

> I hacked up a sample implementation that, as far as I can tell, covers
> the entire specification (Alternative 1 because I'm lazy).

Thanks!  That looks pretty good.  Two nits:

> (define-syntax set! let*
>   (syntax-rules ()
>     ((set! (?e0 ?e1 ...) ?v)
>      ((setter ?e0) ?e1 ... ?v))
>     ((set! ?i ?v)
>      (set! ?i ?v))))

Why the question-marks?  It makes it look like they have
some syntactic signifigance, but it is really just a
naming convention.  Is it a common naming convention?
I haven't really it noticed before.  To me (who have done
my of my programing in C/C++/Java), the question marks are
visually distracting.

>              (set-setter!
>               (lambda (proc setter)
>                 (set! setters (cons (cons proc setter) setters))
>                 (unspecified))))

Some implementors may just use the sample implementation,
though that is of course a bad idea for code that actually
uses setters heavily.  We could at least make sure that the
setters list doesn't fill up with duplicates.  (I realize I did
propose that changing a setter should be undefined, in which
case the concern duplicates is irrelevant.  However, you yourself
suggested that we should allow setters to be redefined.) 

             (set-setter!
              (lambda (proc setter)
                (let ((probe (assq proc setters)))
                  (if probe
                    (set-cdr! probe setter) 
                  (set! setters (cons (cons proc setter) setters))))
                (unspecified))))

-- 
	--Per Bothner
per@xxxxxxxxxxx   http://www.bothner.com/~per/