[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: srfi-39 implementation
Jose A. Ortega Ruiz
Re: srfi-39 implementation
Mon, 10 May 2004 02:21:06 +0200
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)
Please find attached a new version of SRFI-39.
Kevin Ryde <address@hidden> writes:
> Paperwork will be required if adopted.
> Tests are vital, you'll never know if it works if you don't exercise
> all features.
>> #:use-module (ice-9 syncase)
> I believe syncase is pretty big and not very fast. define-macro or
> similar is probably a better idea. (And with enough quasiquote might
> hide all helpers :).
OK. I've used define-macro this time. Nonetheless, I'm still exporting
the additional procedure with-parameters* because i've found it useful
in other contexts :).
>> (define make-parameter
>> ((val) (make-parameter/helper val (lambda (x) x)))
> `identity' in boot-9.
OK. Of course.
>> (define get-fluid-tag (lambda () 'get-fluid)) ;; arbitrary unique (as per
>> eq?) value
> make-symbol perhaps.
It seems 1.6.4 does not defines `make-symbol'. Since I haven`t
installed the cvs version yet, I've followed Paul's suggestion and
used (list 0).
>> (define (make-parameter/helper val conv)
> How does this stand in comparison to make-mutable-parameter in boot-9?
> Similar but not quite the same?
Yup. Basically the same, except that make-parameter/helper
(substituted by make-parameter in the new code) adds support for
'parameterize' and (in its current version) makes addtional error
>> ((eq? (car new-value) get-fluid-tag) value)
>> ((eq? (car new-value) get-conv-tag) conv)
> Perhaps primitive-make-property or something to associate these,
> instead of a function call. (If I understand what it's trying to do.)
Although you are right in that primitive-make-property & co. can be
used, i think the case-based thing is slightly lighter and maybe even
faster, since no hashtable creation/lookup is involved. Or, at any
rate, the difference should be minimal, and the case-based version is
shorter and, IMHO, simpler (unless I'm not using the property
primitives correctly). I'm attaching a version using case
(srfi-39.scm) and a version using properties (srfi-39-alt.scm), so you
can pick the one you like best :)
>> (define (check a b a-val b-val)
>> (if (not (eqv? (a) a-val)) (error "failure -- a" (a) a-val))
>> (if (not (eqv? (b) b-val)) (error "failure -- b" (b) b-val)))
> No, you should use the test-suite/lib.scm framework.
OK. The attached srfi-39.test contains a test suite using this
Thanks a lot for your time and help.
"People sometimes ask me if it is a sin in the Church of Emacs to use vi.
Using a free version of vi is not a sin; it's a penance". - Richard Stallman
Description: test suite
Description: Alternative impl using properties