From 2094b8d28e1a0f0aa42e60355f8fb5b86161c58d Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 4 Oct 2018 20:17:33 -0700 Subject: [PATCH] Reverse order of args to make-library-import and make last optional. --- src/runtime/library-imports.scm | 26 ++++++++------ tests/runtime/test-library-imports.scm | 48 +++++++++----------------- 2 files changed, 32 insertions(+), 42 deletions(-) diff --git a/src/runtime/library-imports.scm b/src/runtime/library-imports.scm index c86dbaf92..4804c11f2 100644 --- a/src/runtime/library-imports.scm +++ b/src/runtime/library-imports.scm @@ -87,9 +87,9 @@ USA. (filter-map (lambda (name) (let ((filtered (filter name))) (and filtered - (make-library-import filtered + (make-library-import library-name name - library-name)))) + filtered)))) (library-metadata-exports (library-db 'get-metadata library-name))))) ((only) @@ -131,24 +131,28 @@ USA. (or (eq? (car names) (cadr names)) (loop (cdr names))))))) +(define (make-library-import from-library from #!optional to) + (%make-library-import from-library from + (if (default-object? to) from to))) + (define-record-type - (make-library-import to from from-library) + (%make-library-import from-library from to) library-import? - (to library-import-to) + (from-library library-import-from-library) (from library-import-from) - (from-library library-import-from-library)) + (to library-import-to)) (define-print-method library-import? (standard-print-method 'library-import (lambda (import) - (list (library-import-to import) + (list (library-import-from-library import) (library-import-from import) - (library-import-from-library import))))) + (library-import-to import))))) (define (library-import=? e1 e2) - (and (eq? (library-import-to e1) - (library-import-to e2)) + (and (equal? (library-import-from-library e1) + (library-import-from-library e2)) (eq? (library-import-from e1) (library-import-from e2)) - (equal? (library-import-from-library e1) - (library-import-from-library e2)))) \ No newline at end of file + (eq? (library-import-to e1) + (library-import-to e2)))) \ No newline at end of file diff --git a/tests/runtime/test-library-imports.scm b/tests/runtime/test-library-imports.scm index bb2ae80b7..caa56ee29 100644 --- a/tests/runtime/test-library-imports.scm +++ b/tests/runtime/test-library-imports.scm @@ -37,39 +37,25 @@ USA. (parse-define-library-form ex1 test-pathname)) (build-metadata-db)) - (list (make-library-import 'foo-mumble? - 'foo-mumble? - '(foo mumble)) - (make-library-import 'make-foo-mumble - 'make-foo-mumble - '(foo mumble)) - (make-library-import 'foo-mumble-a - 'foo-mumble-a - '(foo mumble)) - (make-library-import 'foo-mumble-b - 'foo-mumble-b - '(foo mumble)) - (make-library-import 'grumble-foo-grumble? + (list (make-library-import '(foo mumble) 'foo-mumble?) + (make-library-import '(foo mumble) 'make-foo-mumble) + (make-library-import '(foo mumble) 'foo-mumble-a) + (make-library-import '(foo mumble) 'foo-mumble-b) + (make-library-import '(foo grumble) 'foo-grumble? - '(foo grumble)) - (make-library-import 'grumble-make-foo-grumble + 'grumble-foo-grumble?) + (make-library-import '(foo grumble) 'make-foo-grumble - '(foo grumble)) - (make-library-import 'grumble-foo-grumble-a + 'grumble-make-foo-grumble) + (make-library-import '(foo grumble) 'foo-grumble-a - '(foo grumble)) - (make-library-import 'grumble-foo-grumble-b + 'grumble-foo-grumble-a) + (make-library-import '(foo grumble) 'foo-grumble-b - '(foo grumble)) - (make-library-import 'foo-quux? - 'foo-quux? - '(foo quux)) - (make-library-import 'foo-quux-a - 'foo-quux-a - '(foo quux)) - (make-library-import 'foo-quux-b - 'foo-quux-b - '(foo quux)) - (make-library-import 'create-foo-quux + 'grumble-foo-grumble-b) + (make-library-import '(foo quux) 'foo-quux?) + (make-library-import '(foo quux) 'foo-quux-a) + (make-library-import '(foo quux) 'foo-quux-b) + (make-library-import '(foo quux) 'make-foo-quux - '(foo quux)))))) \ No newline at end of file + 'create-foo-quux))))) \ No newline at end of file -- 2.25.1