Hi, [Keeping the list CC’d.]
Stefan <stefan.ta...@spray.se> writes: > Question? should we make it lean and just allow sfri-9 or perhaps > allow for both styles of records? Actually, record matching in Wright’s match assumes users follow a simple naming convention for the type predicate (only for the type predicate in fact, not for accessors as I thought before.) Then it also assumes to be able to access record fields directly (e.g., with (struct-ref x n)), not through field accessors. This part is in theory specific to a given record implementation, though in practice Guile’s records and SRFI-9 implementations can both be accessed as raw structs with zero-indexed fields: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (eq? (struct-ref (current-module) 0) (module-obarray (current-module))) $2 = #t scheme@(guile-user)> (use-modules (srfi srfi-9)) scheme@(guile-user)> (define-record-type foo (make-foo x y) foo? (x foo-x)(y foo-y)) scheme@(guile-user)> (let ((x (make-foo 'x 'y))) (eq? (foo-x x) (struct-ref x 0))) $3 = #t --8<---------------cut here---------------end--------------->8--- (Guile also has other record types: SRFI-35 error conditions, GOOPS objects, and R6RS records, which Julian recently implemented in the ‘wip-r6rs-libraries’ branch. There might be others floating around, who knows. ;-)) [...] >> As noted in Shinn’s match-cond-expand.scm, this record matching form is >> not ideal: >> >> ;; Annoying unhygienic record matching. Record patterns look like >> ;; ($ record fields...) >> ;; where the record name simply assumes that the same name suffixed >> ;; with a "?" is the correct predicate. >> >> Thanks! >> >> Ludo’. > > Exactly what do you mean by unhygien. (The excerpt above is by Alex Shinn.) It’s unhygienic in the sense that it introduces a reference to a binding that is to be looked up at the point where the macro is expanded, and which may or may not be bound. (See <http://en.wikipedia.org/wiki/Hygienic_macro> for an intro on this topic.) Right below, Shinn writes: ;; Why not just require the "?" to begin with?! Indeed, requiring users to enter the record type predicate, instead of the record type name, would make the macro hygienic, and would be just as convenient: (match x (($ foo? x y) (list x y))) Thanks, Ludo’.