[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#63135] [PATCH 0/3] MATCH-RECROD improvements
From: |
Ludovic Courtès |
Subject: |
[bug#63135] [PATCH 0/3] MATCH-RECROD improvements |
Date: |
Fri, 19 May 2023 17:22:48 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
Hi,
Thanks for these much welcome improvements!
"(" <paren@disroot.org> skribis:
> * guix/records.scm (match-record): Raise a human-compherensible syntax error
> if the given record type identifier is unbound.
[...]
> (define-syntax map-fields
> (lambda (x)
> - (syntax-violation 'map-fields "bad use of syntactic keyword" x x)))
> + (syntax-case x ()
> + ((_ type within)
> + (syntax-violation (syntax->datum #'within)
> + "undefined guix record-type"
> + #'type))
How about “invalid record type identifier”?
(Rule of thumb: never use “Guix” in messages and interfaces.)
> - ((_ map-fields macro)
> + ((_ (map-fields _ _) macro)
> #'(macro (field ...)))
> (id
> (identifier? #'id)
> @@ -595,7 +600,7 @@ (define-syntax match-record-inner
> #'(let-syntax ((field-offset (syntax-rules ()
> ((_ f)
> (lookup-field field 0 f)))))
> - (let* ((offset (type map-fields field-offset))
> + (let* ((offset (type (map-fields type match-record) field-offset))
There’s always a tradeoff; not a strong opinion but I’d lean towards
keeping the macro unchanged (thus a bit simpler) and simply changing the
default ‘syntax-violation’ message above.
WDYT?
Ludo’.
- [bug#63135] [PATCH 0/3] MATCH-RECROD improvements,
Ludovic Courtès <=
[bug#63135] [PATCH 0/3] MATCH-RECROD improvements, Ludovic Courtès, 2023/05/19