* module/srfi/srfi-9/gnu.mes: New file. Support srfi-9-gnu.
* tests/srfi-9.test: Test it.
* tests/srfi-9.test-guile:
mes/bytevectors.scm
mes/elf.scm
mes/guile.scm
+mes/test.scm
mes/M1.scm"
export srcdir=.
tests/math.test
tests/vector.test
tests/srfi-1.test
+tests/srfi-9.test
tests/srfi-13.test
tests/srfi-14.test
tests/srfi-43.test
tests/optargs.test
tests/fluids.test
tests/catch.test
-tests/record.test
tests/getopt-long.test
tests/guile.test
tests/syntax.test
;;; Code:
-(mes-use-module (mes base))
+(cond-expand
+ (mes
+ (mes-use-module (mes base)))
+ (else))
+
(cond-expand
(mes
(define mes? #t)
--- /dev/null
+;;; -*-scheme-*-
+
+;;; Mes --- Maxwell Equations of Software
+;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;;
+;;; This file is part of Mes.
+;;;
+;;; Mes is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; Mes is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (mes test))
+(include-from-path "mes/test.mes")
(define (record-getter type field)
(let ((i (record-field-index type field)))
- (lambda (o)
+ (lambda (o . field?)
(if (not (eq? (record-type o) type)) (error "record getter: record expected" type o)
- (vector-ref o i)))))
+ (if (pair? field?) field
+ (vector-ref o i))))))
(define (record-setter type field)
(let ((i (record-field-index type field)))
--- /dev/null
+;;; -*-scheme-*-
+
+;;; Mes --- Maxwell Equations of Software
+;;; Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;;
+;;; This file is part of Mes.
+;;;
+;;; Mes is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; Mes is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;; srfi-9.mes - GNU immutable records.
+
+(define-macro (define-immutable-record-type type constructor+params predicate . fields)
+ `(define-record-type ,type ,constructor+params ,predicate ,@(map (lambda (f) (list-head f 2)) fields)))
+
+(define-macro (set-field o getters value)
+ `(let ((getter ,(car getters)))
+ (let ((type (record-type ,o))
+ (set (getter ,o #t)))
+ (define (field->value field)
+ (if (eq? set field) ,value
+ ((record-getter type field) ,o)))
+ (let* ((fields (record-fields type))
+ (values (map field->value fields)))
+ (apply (record-constructor type fields) values)))))
+++ /dev/null
-#! /bin/sh
-# -*-scheme-*-
-MES=${MES-$(dirname $0)/../src/mes}
-$MES -s $0
-exit $?
-!#
-
-;;; -*-scheme-*-
-
-;;; Mes --- Maxwell Equations of Software
-;;; Copyright © 2016,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
-;;;
-;;; This file is part of Mes.
-;;;
-;;; Mes is free software; you can redistribute it and/or modify it
-;;; under the terms of the GNU General Public License as published by
-;;; the Free Software Foundation; either version 3 of the License, or (at
-;;; your option) any later version.
-;;;
-;;; Mes is distributed in the hope that it will be useful, but
-;;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-;;; GNU General Public License for more details.
-;;;
-;;; You should have received a copy of the GNU General Public License
-;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
-
-(mes-use-module (srfi srfi-0))
-(mes-use-module (srfi srfi-9))
-(mes-use-module (mes test))
-
-(cond-expand
- (guile
- (use-modules (srfi srfi-9)))
- (mes))
-
-(pass-if "first dummy" #t)
-(pass-if-not "second dummy" #f)
-
-(define-record-type lexical-token
- (make-lexical-token category source value)
- lexical-token?
- (category lexical-token-category)
- (source lexical-token-source)
- (value lexical-token-value))
-
-(pass-if "record"
- (lexical-token? (make-lexical-token 'x 'y 'z)))
-
-(result 'report)
+++ /dev/null
-base.test-guile
\ No newline at end of file
--- /dev/null
+#! /bin/sh
+# -*-scheme-*-
+MES=${MES-$(dirname $0)/../src/mes}
+$MES -s $0
+exit $?
+!#
+
+;;; -*-scheme-*-
+
+;;; Mes --- Maxwell Equations of Software
+;;; Copyright © 2016,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
+;;;
+;;; This file is part of Mes.
+;;;
+;;; Mes is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; Mes is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Mes. If not, see <http://www.gnu.org/licenses/>.
+
+
+(cond-expand
+ (mes
+ (mes-use-module (srfi srfi-9))
+ (mes-use-module (srfi srfi-9 gnu))
+ (mes-use-module (mes test)))
+ (guile
+ (use-modules (srfi srfi-9))
+ (use-modules (srfi srfi-9 gnu))
+ (use-modules (mes test))))
+
+(pass-if "first dummy" #t)
+(pass-if-not "second dummy" #f)
+
+(define-record-type lexical-token
+ (make-lexical-token category source value)
+ lexical-token?
+ (category lexical-token-category)
+ (source lexical-token-source)
+ (value lexical-token-value))
+
+(pass-if "record"
+ (lexical-token? (make-lexical-token 'x 'y 'z)))
+
+(pass-if-equal "set-field" "baar"
+ (let ((token (make-lexical-token 'foo "bar" 'baz)))
+ (lexical-token-category (set-field token (lexical-token-category) "baar"))))
+
+(result 'report)
--- /dev/null
+base.test-guile
\ No newline at end of file