[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
04/08: records: Use keyword parameters for 'make-syntactic-constructor'.
From: |
Ludovic Courtès |
Subject: |
04/08: records: Use keyword parameters for 'make-syntactic-constructor'. |
Date: |
Mon, 19 Jan 2015 22:31:27 +0000 |
civodul pushed a commit to branch master
in repository guix.
commit 9b543456d751eff094a52e98ecebc8030542f728
Author: Ludovic Courtès <address@hidden>
Date: Mon Jan 19 22:27:58 2015 +0100
records: Use keyword parameters for 'make-syntactic-constructor'.
* guix/records.scm (define-record-type*)[make-syntactic-constructor]:
Turn THUNKED and DEFAULTS into keyword arguments.
Adjust caller accordingly. Declare 'thunked' and 'defaults' local
variables.
---
guix/records.scm | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/guix/records.scm b/guix/records.scm
index e7b86af..c833fdb 100644
--- a/guix/records.scm
+++ b/guix/records.scm
@@ -78,7 +78,8 @@ It is possible to copy an object 'x' created with 'thing'
like this:
This expression returns a new object equal to 'x' except for its 'name'
field."
- (define (make-syntactic-constructor type name ctor fields thunked defaults)
+ (define* (make-syntactic-constructor type name ctor fields
+ #:key thunked defaults)
"Make the syntactic constructor NAME for TYPE, that calls CTOR, and
expects all of FIELDS to be initialized. DEFAULTS is the list of
FIELD/DEFAULT-VALUE tuples, and THUNKED is the list of identifiers of
@@ -219,7 +220,10 @@ thunked fields."
(syntax-case s ()
((_ type syntactic-ctor ctor pred
(field get options ...) ...)
- (let* ((field-spec #'((field get options ...) ...)))
+ (let* ((field-spec #'((field get options ...) ...))
+ (thunked (filter-map thunked-field? field-spec))
+ (defaults (filter-map field-default-value
+ #'((field options ...) ...))))
(with-syntax (((field-spec* ...)
(map field-spec->srfi-9 field-spec))
((thunked-field-accessor ...)
@@ -236,10 +240,8 @@ thunked fields."
(begin thunked-field-accessor ...)
#,(make-syntactic-constructor #'type #'syntactic-ctor #'ctor
#'(field ...)
- (filter-map thunked-field?
field-spec)
- (filter-map field-default-value
- #'((field options ...)
- ...))))))))))
+ #:thunked thunked
+ #:defaults defaults))))))))
(define* (alist->record alist make keys
#:optional (multiple-value-keys '()))
- branch master updated (109da1c -> 310b32a), Ludovic Courtès, 2015/01/19
- 02/08: gnu: Remove unneeded #:select., Ludovic Courtès, 2015/01/19
- 04/08: records: Use keyword parameters for 'make-syntactic-constructor'.,
Ludovic Courtès <=
- 06/08: records: Factorize value wrapping in the record constructor., Ludovic Courtès, 2015/01/19
- 01/08: gnu: Move guile-charting to (gnu packages plotutils)., Ludovic Courtès, 2015/01/19
- 05/08: records: Move 'make-syntactic-constructor' to the top level., Ludovic Courtès, 2015/01/19
- 03/08: gnu: Make libgnomeprint{,ui} as deprecated., Ludovic Courtès, 2015/01/19
- 08/08: records: Add support for delayed fields., Ludovic Courtès, 2015/01/19
- 07/08: make-syntactic-constructor kwarg default, Ludovic Courtès, 2015/01/19