From 15c54d58064d825cf71507baa05269d03a21caa3 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Mon, 11 Jan 2016 08:41:28 -0500 Subject: Rename (sly record) to (sly records). * sly/record.scm: Delete. * sly/records.scm: New file. * Makefile.am (SOURCES): Remove deleted file. Add new file. --- Makefile.am | 2 +- sly/record.scm | 54 ------------------------------------------------------ sly/records.scm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 sly/record.scm create mode 100644 sly/records.scm diff --git a/Makefile.am b/Makefile.am index 89a1514..89bf94d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,10 +38,10 @@ SOURCES = \ sly/math/transform.scm \ sly/math/tween.scm \ sly/math/vector.scm \ + sly/records.scm \ sly/repl.scm \ sly/signal.scm \ sly/window.scm \ - sly/record.scm \ sly/render/utils.scm \ sly/render/color.scm \ sly/render/camera.scm \ diff --git a/sly/record.scm b/sly/record.scm deleted file mode 100644 index 8221b14..0000000 --- a/sly/record.scm +++ /dev/null @@ -1,54 +0,0 @@ -;;; Sly -;;; Copyright (C) 2015 David Thompson -;;; -;;; This program 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. -;;; -;;; This program 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 this program. If not, see -;;; . - -;;; Commentary: -;; -;; Immutable record type syntax with keyword argument constructor, -;; field inheritance, and default field values. -;; -;;; Code: - -(define-module (sly record) - #:use-module (srfi srfi-9) - #:export (define-record-type*)) - -(define-syntax-rule (define-record-type* type - constructor keyword-constructor - predicate - (field getter default) ...) - "Define a new, immutable record type named TYPE. PREDICATE is the -name of the procedure that tests if an object is of TYPE. A GETTER is -the name of the accessor for its respective FIELD. CONSTRUCTOR is the -name of the record type's low-level constructor that uses positional -arguments corresponding to the order in which the fields are -specified. KEYWORD-CONSTRUCTOR is the name of the high-level -constructor that uses keyword arguments for each FIELD whose values -correspond to the DEFAULT associated with that field. Additionally, a -special keyword, #:inherit, can be used to copy values from another -instance of TYPE and only change the fields that are explicitly -overridden." - (begin - (define-record-type type - (constructor field ...) - predicate - (field getter) ...) - - (define keyword-constructor - (let ((default-record (constructor default ...))) - (lambda* (#:key (inherit default-record) - (field (getter inherit)) ...) - (constructor field ...)))))) diff --git a/sly/records.scm b/sly/records.scm new file mode 100644 index 0000000..a7e180d --- /dev/null +++ b/sly/records.scm @@ -0,0 +1,54 @@ +;;; Sly +;;; Copyright (C) 2015 David Thompson +;;; +;;; This program 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. +;;; +;;; This program 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 this program. If not, see +;;; . + +;;; Commentary: +;; +;; Immutable record type syntax with keyword argument constructor, +;; field inheritance, and default field values. +;; +;;; Code: + +(define-module (sly records) + #:use-module (srfi srfi-9) + #:export (define-record-type*)) + +(define-syntax-rule (define-record-type* type + constructor keyword-constructor + predicate + (field getter default) ...) + "Define a new, immutable record type named TYPE. PREDICATE is the +name of the procedure that tests if an object is of TYPE. A GETTER is +the name of the accessor for its respective FIELD. CONSTRUCTOR is the +name of the record type's low-level constructor that uses positional +arguments corresponding to the order in which the fields are +specified. KEYWORD-CONSTRUCTOR is the name of the high-level +constructor that uses keyword arguments for each FIELD whose values +correspond to the DEFAULT associated with that field. Additionally, a +special keyword, #:inherit, can be used to copy values from another +instance of TYPE and only change the fields that are explicitly +overridden." + (begin + (define-record-type type + (constructor field ...) + predicate + (field getter) ...) + + (define keyword-constructor + (let ((default-record (constructor default ...))) + (lambda* (#:key (inherit default-record) + (field (getter inherit)) ...) + (constructor field ...)))))) -- cgit v1.2.3