Hi Neil, Neil Jerram <[email protected]> writes:
> [email protected] (Ludovic Courtès) writes: [...] >> In the ‘wip-vlist’ branch (which is about implementing Bagwell’s vlists) >> SRFI-9 is reimplemented in terms of raw structs, instead of records. > > Well I enjoyed a bit of reading, and I don't see any problem with these > changes, but I don't see why "it makes it easy to write a > macro-generating macro akin to Dybvig’s ‘define-integrable’". Couldn't > that have been achieved just by rewriting the SRFI-9 define-macro as > define-syntax, but still using make-record-type etc.? The problem with records is that accessors are defined with ‘record-accessor’, as in: (define module-name (record-accessor module-type 'name)) Here, ‘record-accessor’ returns a procedure. Until the compiler has a smart inliner, each ‘module-name’ call is actually a procedure call. Conversely, the ‘define-inlineable’ macro in srfi-9.scm leads to accessor definitions along these lines: (define module-name-procedure (lambda (x) (struct-ref x 0))) (define-syntax module-name (lambda (x) (syntax-case x () ((_ obj) #'(struct-ref obj 0)) (_ #'module-name-procedure)))) Thus, an expression like ‘(module-name (current-module))’ is effectively expanded to ‘(struct-ref (current-module) 0)’, whereas ‘(procedure? module-name)’ is expanded to ‘(procedure? module-name-procedure)’. IOW, this is a poor man’s inliner. But still, I find the approach pretty neat. :-) Thanks, Ludo’.
