From 1ba6978e7b5b47b894098aa0b745c145f12308ed Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Mon, 24 Jul 2023 17:27:31 +0300 Subject: Replace set! mutations with an alist Signed-off-by: Munyoki Kilyungi --- dump/special-forms.scm | 112 ++++++++++++++++++++++--------------------------- 1 file changed, 49 insertions(+), 63 deletions(-) diff --git a/dump/special-forms.scm b/dump/special-forms.scm index fce3a11..ad3296e 100644 --- a/dump/special-forms.scm +++ b/dump/special-forms.scm @@ -549,66 +549,52 @@ The above query results to triples that have the form: (define-syntax dump-with-documentation (syntax-rules () ((_ (key value) ...) - (let ((name "") - (connection "") - (table-metadata? "") - (prefixes "") - (inputs "") - (outputs "")) - (for-each - (match-lambda - (('name n) - (set! name n)) - (('connection conn) - (set! connection conn)) - (('table-metadata? t-metadata?) - (set! table-metadata? t-metadata?)) - (('prefixes p) - (set! prefixes p)) - (('inputs i) - (set! inputs i)) - (('outputs o) - (set! outputs o))) - (list (list 'key value) ...)) - (let ((rdf-path (get-keyword-value outputs #:rdf "")) - (doc-path (get-keyword-value outputs #:documentation ""))) - ;; Dumping the documentation first - (call-with-target-database - connection - (lambda (db) - (with-output-to-file ; - doc-path - (lambda () - (format #t "# ~a" name) - (for-each - (lambda (proc) - (proc db - #:dump-metadata? #f - #:dump-data? #f - #:dump-documentation? - (lambda () (for-each - (match-lambda - ((k v) - (begin - (prefix k v #f)))) - prefixes)))) - inputs)) - #:encoding "utf8") - - ;; Dumping the actual data - (with-output-to-file - rdf-path - (lambda () - ;; Add the prefixes - (for-each - (match-lambda - ((k v) - (begin - (prefix k v)))) - prefixes) - (newline) - (for-each - (lambda (proc) - (proc db #:dump-metadata? table-metadata?)) - inputs)) - #:encoding "utf8")))))))) + (let* ((alist `((key . ,value) ...)) + (name (assoc-ref alist 'name)) + (connection (assoc-ref alist 'connection)) + (table-metadata? (assoc-ref alist 'table-metadata?)) + (prefixes (assoc-ref alist 'prefixes)) + (inputs (assoc-ref alist 'inputs)) + (outputs (assoc-ref alist 'outputs)) + (rdf-path (get-keyword-value outputs #:rdf "")) + (doc-path (get-keyword-value outputs #:documentation ""))) + (call-with-target-database + connection + (lambda (db) + (with-output-to-file ; + doc-path + (lambda () + (format #t "# ~a" name) + (for-each + (lambda (proc) + (proc db + #:dump-metadata? #f + #:dump-data? #f + #:dump-documentation? + (lambda () (for-each + (match-lambda + ((k v) + (begin + (prefix k v #f)))) + prefixes)))) + inputs)) + #:encoding "utf8") + + ;; Dumping the actual data + (with-output-to-file + rdf-path + (lambda () + ;; Add the prefixes + (for-each + (match-lambda + ((k v) + (begin + (prefix k v)))) + prefixes) + (newline) + (for-each + (lambda (proc) + (proc db #:dump-metadata? table-metadata?)) + inputs)) + #:encoding "utf8"))))))) + -- cgit v1.2.3