Commit Graph

11 Commits (9b543456d751eff094a52e98ecebc8030542f728)

Author SHA1 Message Date
Ludovic Courtès 9b543456d7 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.
2015-01-19 23:30:42 +01:00
Ludovic Courtès fb519bd831 records: Optimize 'recutils->alist' by avoiding regexps.
* guix/records.scm (%recutils-field-rx, %recutils-comment-rx,
  %recutils-plus-rx): Remove.
  (%recutils-field-charset): New variable.
  (recutils->alist): Adjust to use tests (string-ref line 0) instead of
  regexps.
2015-01-09 01:08:10 +01:00
Ludovic Courtès e25408849a records: Improve the docstring of 'define-record-type*'.
* guix/records.scm (define-record-type*): Agument the docstring, give
  examples.
2014-10-17 23:23:20 +02:00
Ludovic Courtès a1906758c3 records: Report unknown field names in inheriting forms.
* guix/records.scm (define-record-type*)[record-inheritance]: Check for
  unexpected field names.
* tests/records.scm ("define-record-type* with let* behavior"): Return
  #t, not *unspecified*.
  ("define-record-type* & inherit & extra initializers"): New test.
2014-07-17 16:45:45 +02:00
Ludovic Courtès b1353e7a6b records: Factorize error-reporting macro.
* guix/records.scm (record-error): New macro.
  (define-record-type*)[error*]: Remove.
  Use 'record-error' instead.
2014-07-17 16:42:19 +02:00
Ludovic Courtès 59fbeb8cae records: define-record-type*: Field bindings are bound with 'let*'.
* guix/records.scm (define-record-type*): Wrap field bindings in a
  'let*', not in a 'letrec*', which turned out to be pointlessly
  inconvenient.
* tests/records.scm: Adjust test names accordingly.
2013-10-15 23:31:22 +02:00
Ludovic Courtès 836d10f154 records: `recutils->alist' recognizes lines starting with a `+'.
* guix/records.scm (%recutils-plus-rx): New variable.
  (recutils->alist): Use it to read + lines.
* tests/records.scm ("recutils->alist with + lines"): New test.
2013-07-10 21:53:29 +02:00
Ludovic Courtès c8772a7a21 records: `alist->record' supports multiple-field occurrences.
* guix/records.scm (alist->record): Add `multiple-value-keys'
  parameter.  Update docstring, and honor it.
* tests/records.scm ("alist->record"): New record.
2013-07-10 21:52:51 +02:00
Ludovic Courtès b7b8828801 records: `recutils->alist' recognizes comments.
* guix/records.scm (%recutils-comment-rx): New variable.
  (recutils->alist): Match comments.
* tests/records.scm ("recutils->alist"): Add comments.
2013-07-10 18:01:12 +02:00
Ludovic Courtès fdc1bf659d records: Add `recutils->alist' for public consumption.
* guix/records.scm (%recutils-field-rx): New variable.
  (recutils->alist): New procedure, formerly known as `fields->alist'.
* guix/scripts/substitute-binary.scm (fields->alist): Use it.
* tests/records.scm ("recutils->alist"): New test.
2013-07-10 17:01:08 +02:00
Ludovic Courtès c0cd1b3ea7 Move record utilities to (guix records).
* guix/utils.scm (define-record-type*): Move to...
* guix/records.scm: ... here.  New file.
* guix/build-system.scm, guix/packages.scm: Use it.
* guix/gnu-maintenance.scm: Likewise.
  (official-gnu-packages)[alist->record]: Remove.
* guix/scripts/substitute-binary.scm: Likewise.
  (alist->record, object->fields): Remove.
* tests/utils.scm ("define-record-type*", "define-record-type* with
  letrec* behavior", "define-record-type* & inherit",
  "define-record-type* & inherit & letrec* behavior",
  "define-record-type* & thunked", "define-record-type* & thunked &
  default", "define-record-type* & thunked & inherited"): Move to...
* tests/records.scm: ... here.  New file.
2013-05-12 15:46:16 +02:00