From fb252fc22dc97debe7cbcdd3622283982133dd0a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 01:13:05 +0900 Subject: [PATCH 001/118] Add new test `r5rs` --- CMakeLists.txt | 1 + README.md | 6 +- VERSION | 2 +- test/r5rs.ss | 953 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 958 insertions(+), 4 deletions(-) create mode 100644 test/r5rs.ss diff --git a/CMakeLists.txt b/CMakeLists.txt index 0daeca1e4..c5b5e944d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,6 +172,7 @@ check(low-level-macro-facility) check(numerical-operations) check(r4rs) check(r4rs-appendix) +check(r5rs) check(r7rs) check(sicp-1) check(srfi-8) diff --git a/README.md b/README.md index 3068fccbd..48774046e 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.818.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.822.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.818_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.822_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.818 +Meevax Lisp System, version 0.3.822 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index cc56a1de6..2d69fdbf2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.818 +0.3.822 diff --git a/test/r5rs.ss b/test/r5rs.ss new file mode 100644 index 000000000..af0de0db5 --- /dev/null +++ b/test/r5rs.ss @@ -0,0 +1,953 @@ +; ---- 1.3.4 ------------------------------------------------------------------- + +(check (* 5 8) => 40) + +; ---- 4.1.1 ------------------------------------------------------------------- + +(define x 28) + +(check x => 28) + +; ---- 4.1.2 ------------------------------------------------------------------- + +(check (quote a) => a) + +(check (quote #(a b c)) => #(a b c)) + +(check (quote (+ 1 2)) => (+ 1 2)) + +(check 'a => a) + +(check '#(a b c) => #(a b c)) + +(check '() => ()) + +(check '(+ 1 2) => (+ 1 2)) + +(check '(quote a) => (quote a)) + +(check ''a => (quote a)) + +(check '"abc" => "abc") + +(check "abc" => "abc") + +(check '145932 => 145932) + +(check 145932 => 145932) + +(check '#t => #t) + +(check #t => #t) + +; ---- 4.1.3 ------------------------------------------------------------------- + +(check (+ 3 4) => 7) + +(check ((if #f + *) 3 4) => 12) + +; ---- 4.1.4 ------------------------------------------------------------------- + +(check (procedure? (lambda (x) (+ x x))) => #t) + +(check ((lambda (x) (+ x x)) 4) => 8) + +(define reverse-subtract + (lambda (x y) + (- y x))) + +(check (reverse-subtract 7 10) => 3) + +(define add4 + (let ((x 4)) + (lambda (y) (+ x y)))) + +(check (add4 6) => 10) + +(check ((lambda x x) 3 4 5 6) => (3 4 5 6)) + +(check ((lambda (x y . z) z) 3 4 5 6) => (5 6)) + +; ---- 4.1.5 ------------------------------------------------------------------- + +(check (if (> 3 2) 'yes 'no) => yes) + +(check (if (> 2 3) 'yes 'no) => no) + +(check (if (> 3 2) + (- 3 2) + (+ 3 2)) => 1) + +; ---- 4.1.6 ------------------------------------------------------------------- + +(define x 2) + +(check (+ x 1) => 3) + +(check (set! x 4) => 4) + +(check (+ x 1) => 5) + +; ---- 4.2.1 ------------------------------------------------------------------- + +(check (cond ((> 3 2) 'greater) + ((< 3 2) 'less)) => greater) + +(check (cond ((> 3 3) 'greater) + ((< 3 3) 'less) + (else 'equal)) => equal) + +(check (cond ((assv 'b '((a 1) (b 2))) => cadr) + (else #f)) => 2) + +(check (case (* 2 3) + ((2 3 5 7) 'prime) + ((1 4 6 8 9) 'composite)) => composite) + +(check (case (car '(c d)) + ((a) 'a) + ((b) 'b)) => #,(unspecified)) + +(check (case (car '(c d)) + ((a e i o u) 'vowel) + ((w y) 'semivowel) + (else 'consonant)) => consonant) + +(check (and (= 2 2) (> 2 1)) => #t) + +(check (and (= 2 2) (< 2 1)) => #f) + +(check (and 1 2 'c '(f g)) => (f g)) + +(check (and) => #t) + +(check (or (= 2 2) (> 2 1)) => #t) + +(check (or (= 2 2) (< 2 1)) => #t) + +(check (or #f #f #f) => #f) + +(check (or (memq 'b '(a b c)) (/ 3 0)) => (b c)) + +; ---- 4.2.2 ------------------------------------------------------------------- + +(check (let ((x 2) + (y 3)) + (* x y)) => 6) + +(check (let ((x 2) + (y 3)) + (let ((x 7) + (z (+ x y))) + (* z x))) => 35) + +(check (let ((x 2) + (y 3)) + (let* ((x 7) + (z (+ x y))) + (* z x))) => 70) + +(check (letrec ((even? (lambda (n) + (if (zero? n) #t + (odd? (- n 1))))) + (odd? (lambda (n) + (if (zero? n) #f + (even? (- n 1)))))) + (even? 88)) => #t) + +; ---- 4.2.3 ------------------------------------------------------------------- + +(define x 0) + +(check (begin (set! x 5) + (+ x 1)) => 6) + +(check (begin (display "4 plus 1 equals ") + (display (+ 4 1))) => #,(unspecified)) + +; ---- 4.2.4 ------------------------------------------------------------------- + +(check (do ((vec (make-vector 5)) + (i 0 (+ i 1))) + ((= i 5) vec) + (vector-set! vec i i)) => #(0 1 2 3 4)) + +(check (let ((x '(1 3 5 7 9))) + (do ((x x (cdr x)) + (sum 0 (+ sum (car x)))) + ((null? x) sum))) => 25) + +(check (let loop ((numbers '(3 -2 1 6 -5)) + (nonneg '()) + (neg '())) + (cond ((null? numbers) (list nonneg neg)) + ((<= 0 (car numbers)) + (loop (cdr numbers) + (cons (car numbers) nonneg) + neg)) + ((< (car numbers) 0) + (loop (cdr numbers) + nonneg + (cons (car numbers) neg))))) => ((6 1 3) (-5 -2))) + +; ---- 4.2.6 ------------------------------------------------------------------- + +(check `(list ,(+ 1 2) 4) => (list 3 4)) + +(check (let ((name 'a)) `(list ,name ',name)) => (list a (quote a))) + +(check `(a ,(+ 1 2) ,@(map abs '(4 -5 6)) b) => (a 3 4 5 6 b)) + +(check `((foo ,(- 10 3)) ,@(cdr '(c)) . ,(car '(cons))) => ((foo 7) . cons)) + +(check `#(10 5 ,(sqrt 4) ,@(map sqrt '(16 9)) 8) => #(10 5 2 4 3 8)) + +; (check `(a `(b ,(+ 1 2) ,(foo ,(+ 1 3) d) e) f) => (a `(b ,(+ 1 2) ,(foo 4 d) e) f)) ; ERROR + +; (check (let ((name1 'x) +; (name2 'y)) +; `(a `(b ,,name1 ,'mname2 d) e)) => (a `(b ,x ,'y d) e)) ; ERROR + +; ---- 4.3.1 ------------------------------------------------------------------- + +(check (let-syntax ((when (syntax-rules () + ((when test stmt1 stmt2 ...) + (if test + (begin stmt1 + stmt2 ...)))))) + (let ((if #t)) + (when if (set! if 'now)) + if)) => now) + +; (check (let ((x 'outer)) +; (let-syntax ((m (syntax-rules () ((m) x)))) +; (let ((x 'inner)) +; (m)))) => outer) ; ERROR + +(check (letrec-syntax ((my-or (syntax-rules () + ((my-or) #f) + ((my-or e) e) + ((my-or e1 e2 ...) + (let ((temp e1)) + (if temp + temp + (my-or e2 ...))))))) + (let ((x #f) + (y 7) + (temp 8) + (let odd?) + (if even?)) + (my-or x + (let temp) + (if y) + y))) => 7) + +; ---- 4.3.2 ------------------------------------------------------------------- + +; (check (let ((=> #f)) +; (cond (#t => 'ok))) => ok) ; ERROR + +; ---- 5.2.1 ------------------------------------------------------------------- + +(define add3 + (lambda (x) (+ x 3))) + +(check (add3 3) => 6) + +(define first car) + +(check (first '(1 2)) => 1) + +; ---- 5.2.2 ------------------------------------------------------------------- + +(check (let ((x 5)) + (define foo (lambda (y) (bar x y))) + (define bar (lambda (a b) (+ (* a b) a))) + (foo (+ x 3))) => 45) + +(check (let ((x 5)) + (letrec ((foo (lambda (y) (bar x y))) + (bar (lambda (a b) (+ (* a b) a)))) + (foo (+ x 3)))) => 45) + +; ---- 6.1 --------------------------------------------------------------------- + +(check (eqv? 'a 'a) => #t) + +(check (eqv? 'a 'b) => #f) + +(check (eqv? 2 2) => #t) + +(check (eqv? '() '()) => #t) + +(check (eqv? 100000000 100000000) => #t) + +(check (eqv? (cons 1 2) (cons 1 2)) => #f) + +(check (eqv? (lambda () 1) (lambda () 2)) => #f) + +(check (eqv? #f 'nil) => #f) + +(check (let ((p (lambda (x) x))) + (eqv? p p)) => #t) + +(check (eqv? "" "") => #t) + +(check (eqv? '#() '#()) => #t) + +(check (eqv? (lambda (x) x) + (lambda (x) x)) => #f) + +(check (eqv? (lambda (x) x) + (lambda (y) y)) => #f) + +(define gen-counter + (lambda () + (let ((n 0)) + (lambda () (set! n (+ n 1)) n)))) + +(check (let ((g (gen-counter))) + (eqv? g g)) => #t) + +(check (eqv? (gen-counter) (gen-counter)) => #f) + +(define gen-loser + (lambda () + (let ((n 0)) + (lambda () (set! n (+ n 1)) 27)))) + +(check (let ((g (gen-loser))) + (eqv? g g)) => #t) + +(check (eqv? (gen-loser) (gen-loser)) => #f) + +(check (letrec ((f (lambda () (if (eqv? f g) 'both 'f))) + (g (lambda () (if (eqv? f g) 'both 'g)))) + (eqv? f g)) => #f) + +(check (letrec ((f (lambda () (if (eqv? f g) 'f 'both))) + (g (lambda () (if (eqv? f g) 'g 'both)))) + (eqv? f g)) => #f) + +(check (eqv? '(a) '(a)) => #t) + +(check (eqv? "a" "a") => #t) + +(check (eqv? '(b) (cdr '(a b))) => #t) + +(check (let ((x '(a))) + (eqv? x x)) => #t) + +(check (eq? 'a 'a) => #t) + +(check (eq? '(a) '(a)) => #f) + +(check (eq? (list 'a) (list 'a)) => #f) + +(check (eq? "a" "a") => #f) + +(check (eq? "" "") => #f) + +(check (eq? '() '()) => #t) + +(check (eq? 2 2) => #f) + +(check (eq? #\A #\A) => #f) + +(check (eq? car car) => #t) + +(check (let ((n (+ 2 3))) + (eq? n n)) => #t) + +(check (let ((x '(a))) + (eq? x x)) => #t) + +(check (let ((x '#())) + (eq? x x)) => #t) + +(check (let ((p (lambda (x) x))) + (eq? p p)) => #t) + +(check (equal? 'a 'a) => #t) + +(check (equal? '(a) '(a)) => #t) + +(check (equal? '(a (b) c) '(a (b) c)) => #t) + +(check (equal? "abc" "abc") => #t) + +(check (equal? 2 2) => #t) + +(check (equal? (make-vector 5 'a) (make-vector 5 'a)) => #t) + +(check (equal? (lambda (x) x) (lambda (y) y)) => #f) + +; ---- 6.2.5 ------------------------------------------------------------------- + +(check (complex? 3+4i) => #t) + +(check (complex? 3) => #t) + +(check (real? 3) => #t) + +(check (real? -2.5+0.0i) => #t) + +(check (real? #e1e10) => #t) + +(check (rational? 6/10) => #t) + +(check (rational? 6/3) => #t) + +(check (integer? 3+0i) => #t) + +(check (integer? 3.0) => #t) + +(check (integer? 8/4) => #t) + +(check (max 3 4) => 4) + +(check (max 3.9 4) => 4.0) + +(check (+ 3 4) => 7) + +(check (+ 3) => 3) + +(check (+) => 0) + +(check (* 4) => 4) + +(check (*) => 1) + +(check (- 3 4) => -1) + +(check (- 3 4 5) => -6) + +(check (- 3) => -3) + +(check (/ 3 4 5) => 3/20) + +(check (/ 3) => 1/3) + +(check (abs -7) => 7) + +(check (modulo 13 4) => 1) + +(check (remainder 13 4) => 1) + +(check (modulo -13 4) => 3) + +(check (remainder -13 4) => -1) + +(check (modulo 13 -4) => -3) + +(check (remainder 13 -4) => 1) + +(check (modulo -13 -4) => -1) + +(check (remainder -13 -4) => -1) + +(check (remainder -13 -4.0) => -1.0) + +(check (gcd 32 -36) => 4) + +(check (gcd) => 0) + +(check (lcm 32 -36) => 288) + +(check (lcm 32.0 -36) => 288.0) + +(check (lcm) => 1) + +(check (numerator (/ 6 4)) => 3) + +(check (denominator (/ 6 4)) => 2) + +(check (denominator (exact->inexact (/ 6 4))) => 2.0) + +(check (floor -4.3) => -5.0) + +(check (ceiling -4.3) => -4.0) + +(check (truncate -4.3) => -4.0) + +(check (round -4.3) => -4.0) + +(check (floor 3.5) => 3.0) + +(check (ceiling 3.5) => 4.0) + +(check (truncate 3.5) => 3.0) + +(check (round 3.5) => 4.0) + +(check (round 7/2) => 4) + +(check (round 7) => 7) + +; ---- 6.2.6 ------------------------------------------------------------------- + +(check (string->number "100") => 100) + +(check (string->number "100" 16) => 256) + +(check (string->number "1e2") => 100.0) + +; (check (string->number "15##") => 1500.0) ; ERROR + +; ---- 6.3.1 ------------------------------------------------------------------- + +(check #t => #t) + +(check #f => #f) + +(check '#f => #f) + +(check (not #t) => #f) + +(check (not 3) => #f) + +(check (not (list 3)) => #f) + +(check (not #f) => #t) + +(check (not '()) => #f) + +(check (not (list)) => #f) + +(check (not 'nil) => #f) + +(check (boolean? #f) => #t) + +(check (boolean? 0) => #f) + +(check (boolean? '()) => #f) + +; ---- 6.3.2 ------------------------------------------------------------------- + +(define x (list 'a 'b 'c)) + +(define y x) + +(check y => (a b c)) + +(check (list? y) => #t) + +(set-cdr! x 4) + +(check x => (a . 4)) + +(check (eqv? x y) => #t) + +(check y => (a . 4)) + +(check (list? y) => #f) + +(set-cdr! x x) + +(check (list? x) => #f) + +(check (pair? '(a . b)) => #t) + +(check (pair? '(a b c)) => #t) + +(check (pair? '()) => #f) + +(check (pair? '#(a b)) => #f) + +(check (cons 'a '()) => (a)) + +(check (cons '(a) '(b c d)) => ((a) b c d)) + +(check (cons "a" '(b c)) => ("a" b c)) + +(check (cons 'a 3) => (a . 3)) + +(check (cons '(a b) 'c) => ((a b) . c)) + +(check (car '(a b c)) => a) + +(check (car '((a) b c d)) => (a)) + +(check (car '(1 . 2)) => 1) + +(check (cdr '((a) b c d)) => (b c d)) + +(check (cdr '(1 . 2)) => 2) + +(define (f) (list 'not-a-constant-list)) + +(define (g) '(constant-list)) + +(check (set-car! (f) 3) => 3) + +(check (set-car! (g) 3) => 3) + +(check (list? '(a b c)) => #t) + +(check (list? '()) => #t) + +(check (list? '(a . b)) => #f) + +(check (let ((x (list 'a))) + (set-cdr! x x) + (list? x)) => #f) + +(check (list 'a (+ 3 4) 'c) => (a 7 c)) + +(check (list) => ()) + +(check (length '(a b c)) => 3) + +(check (length '(a (b) (c d e))) => 3) + +(check (length '()) => 0) + +(check (append '(x) '(y)) => (x y)) + +(check (append '(a) '(b c d)) => (a b c d)) + +(check (append '(a (b)) '((c))) => (a (b) (c))) + +(check (append '(a b) '(c . d)) => (a b c . d)) + +(check (append '() 'a) => a) + +(check (reverse '(a b c)) => (c b a)) + +(check (reverse '(a (b c) d (e (f)))) => ((e (f)) d (b c) a)) + +(define list-tail + (lambda (x k) + (if (zero? k) + x + (list-tail (cdr x) (- k 1))))) + +(check (list-ref '(a b c d) 2) => c) + +(check (list-ref '(a b c d) (inexact->exact (round 1.8))) => c) + +(check (memq 'a '(a b c)) => (a b c)) + +(check (memq 'b '(a b c)) => (b c)) + +(check (memq 'a '(b c d)) => #f) + +(check (memq (list 'a) '(b (a) c)) => #f) + +(check (member (list 'a) '(b (a) c)) => ((a) c)) + +(check (memq 101 '(100 101 102)) => #f) + +(check (memv 101 '(100 101 102)) => (101 102)) + +(define e '((a 1) (b 2) (c 3))) + +(check (assq 'a e) => (a 1)) + +(check (assq 'b e) => (b 2)) + +(check (assq 'd e) => #f) + +(check (assq (list 'a) '(((a)) ((b)) ((c)))) => #f) + +(check (assoc (list 'a) '(((a)) ((b)) ((c)))) => ((a))) + +(check (assq 5 '((2 3) (5 7) (11 13))) => #f) + +(check (assv 5 '((2 3) (5 7) (11 13))) => (5 7)) + +; ---- 6.3.3 ------------------------------------------------------------------- + +(check (symbol? 'foo) => #t) + +(check (symbol? (car '(a b))) => #t) + +(check (symbol? "bar") => #f) + +(check (symbol? 'nil) => #t) + +(check (symbol? '()) => #f) + +(check (symbol? #f) => #f) + +(check (symbol->string 'flying-fish) => "flying-fish") + +(check (symbol->string 'Martin) => "Martin") ; incompatible + +(check (symbol->string (string->symbol "Malvina")) => "Malvina") + +(check (eq? 'mISSISSIppi 'mississippi) => #f) ; incompatible + +(check (string->symbol "mISSISSIppi") => mISSISSIppi) + +(check (eq? 'bitBlt (string->symbol "bitBlt")) => #t) ; incompatible + +(check (eq? 'JollyWog (string->symbol (symbol->string 'JollyWog))) => #t) + +(check (string=? "K. Harper, M.D." (symbol->string (string->symbol "K. Harper, M.D."))) => #t) + +; ---- 6.3.4 ------------------------------------------------------------------- + +(check (char? #\a) => #t) + +(check (char? #\A) => #t) + +(check (char? #\() => #t) + +(check (char? #\ ) => #t) + +(check (char? #\space) => #t) + +(check (char? #\newline) => #t) + +; ---- 6.3.5 ------------------------------------------------------------------- + +(check (string? "The word \"recursion\" has many meanings.") => #t) + +(define (f) (make-string 3 #\*)) + +(define (g) "***") + +(string-set! (f) 0 #\?) + +(string-set! (g) 0 #\?) + +(string-set! (symbol->string 'immutable) 0 #\?) + +; ---- 6.3.6 ------------------------------------------------------------------- + +(check (vector? #(0 (2 2 2 2) "Anna")) => #t) + +(check (vector 'a 'b 'c) => #(a b c)) + +(check (vector-ref '#(1 1 2 3 5 8 13 21) 5) => 8) + +(check (vector-ref '#(1 1 2 3 5 8 13 21) + (let ((i (round (* 2 (acos -1))))) + (if (inexact? i) + (inexact->exact i) + i))) => 13) + +(check (let ((vec (vector 0 '(2 2 2 2) "Anna"))) + (vector-set! vec 1 '("Sue" "Sue")) + vec) => #(0 ("Sue" "Sue") "Anna")) + +(vector-set! '#(0 1 2) 1 "doe") + +(check (vector->list '#(dah dah didah)) => (dah dah didah)) + +(check (list->vector '(dididit dah)) => #(dididit dah)) + +; ---- 6.4 --------------------------------------------------------------------- + +(check (procedure? car) => #t) + +(check (procedure? 'car) => #f) + +(check (procedure? (lambda (x) (* x x))) => #t) + +(check (procedure? '(lambda (x) (* x x))) => #f) + +(check (call-with-current-continuation procedure?) => #t) + +(check (apply + (list 3 4)) => 7) + +(define compose + (lambda (f g) + (lambda args + (f (apply g args))))) + +(check ((compose sqrt *) 12 75) => 30) + +(check (map cadr '((a b) (d e) (g h))) => (b e h)) + +(check (map (lambda (n) (expt n n)) '(1 2 3 4 5)) => (1 4 27 256 3125)) + +(check (map + '(1 2 3) '(4 5 6)) => (5 7 9)) + +(check (let ((count 0)) + (map (lambda (ignored) + (set! count (+ count 1)) + count) + '(a b))) => (1 2)) + +(check (let ((v (make-vector 5))) + (for-each (lambda (i) + (vector-set! v i (* i i))) + '(0 1 2 3 4)) + v) => #(0 1 4 9 16)) + +(check (force (delay (+ 1 2))) => 3) + +(check (let ((p (delay (+ 1 2)))) + (list (force p) (force p))) => (3 3)) + +(define a-stream + (letrec ((next (lambda (n) + (cons n (delay (next (+ n 1))))))) + (next 0))) + +(define head car) + +(define tail + (lambda (stream) (force (cdr stream)))) + +(check (head (tail (tail a-stream))) => 2) + +(define count 0) + +(define p + (delay (begin (set! count (+ count 1)) + (if (> count x) + count + (force p))))) + +(define x 5) + +(check (promise? p) => #t) + +(check (force p) => 6) + +(check (promise? p) => #t) + +(check (begin (set! x 10) + (force p)) => 6) + +(check (eqv? (delay 1) 1) => #f) + +(check (pair? (delay (cons 1 2))) => #t) + +(check (call-with-current-continuation + (lambda (exit) + (for-each (lambda (x) + (if (negative? x) + (exit x))) + '(52 0 37 -3 245 19)) + #t)) => -3) + +(define list-length + (lambda (obj) + (call-with-current-continuation + (lambda (return) + (letrec ((r (lambda (obj) + (cond ((null? obj) 0) + ((pair? obj) + (+ (r (cdr obj)) 1)) + (else (return #f)))))) + (r obj)))))) + +(check (list-length '(1 2 3 4)) => 4) + +(check (list-length '(a b . c)) => #f) + +(check (call-with-values (lambda () (values 4 5)) + (lambda (a b) b)) => 5) + +(check (call-with-values * -) => -1) + +(check (let ((path '()) + (c #f)) + (let ((add (lambda (s) + (set! path (cons s path))))) + (dynamic-wind + (lambda () (add 'connect)) + (lambda () + (add (call-with-current-continuation + (lambda (c0) + (set! c c0) + 'talk1)))) + (lambda () (add 'disconnect))) + (if (< (length path) 4) + (c 'talk2) + (reverse path)))) => (connect talk1 disconnect + connect talk2 disconnect)) + +; ---- 6.5 --------------------------------------------------------------------- + +; (check (eval '(* 7 3) (scheme-report-environment 5)) => 21) ; ERROR + +; (check (let ((f (eval '(lambda (f x) (f x x)) (null-environment 5)))) +; (f + 10)) => 20) ; ERROR + +; ---- EXAMPLE ----------------------------------------------------------------- + +(define integrate-system + (lambda (system-derivative initial-state h) + (let ((next (runge-kutta-4 system-derivative h))) + (letrec ((states + (cons initial-state + (delay (map-streams next + states))))) + states)))) + +(define runge-kutta-4 + (lambda (f h) + (let ((*h (scale-vector h)) + (*2 (scale-vector 2)) + (*1/2 (scale-vector (/ 1 2))) + (*1/6 (scale-vector (/ 1 6)))) + (lambda (y) + ;; y is a system state + (let* ((k0 (*h (f y))) + (k1 (*h (f (add-vectors y (*1/2 k0))))) + (k2 (*h (f (add-vectors y (*1/2 k1))))) + (k3 (*h (f (add-vectors y k2))))) + (add-vectors y + (*1/6 (add-vectors k0 + (*2 k1) + (*2 k2) + k3)))))))) + +(define elementwise + (lambda (f) + (lambda vectors + (generate-vector + (vector-length (car vectors)) + (lambda (i) + (apply f + (map (lambda (v) (vector-ref v i)) + vectors))))))) +(define generate-vector + (lambda (size proc) + (let ((ans (make-vector size))) + (letrec ((loop (lambda (i) + (cond ((= i size) ans) + (else (vector-set! ans i (proc i)) + (loop (+ i 1))))))) + (loop 0))))) + +(define add-vectors (elementwise +)) + +(define scale-vector + (lambda (s) + (elementwise (lambda (x) (* x s))))) + +(define map-streams + (lambda (f s) + (cons (f (head s)) + (delay (map-streams f (tail s)))))) + +(define head car) + +(define tail + (lambda (stream) (force (cdr stream)))) + +(define damped-oscillator + (lambda (R L C) + (lambda (state) + (let ((Vc (vector-ref state 0)) + (Il (vector-ref state 1))) + (vector (- 0 (+ (/ Vc (* R C)) (/ Il C))) + (/ Vc L)))))) + +(define the-states + (integrate-system + (damped-oscillator 10000 1000 .001) + '#(1 0) + .01)) + +; ------------------------------------------------------------------------------ + +(check-report) + +(exit (check-passed? check:correct)) From 1b10d637e21718fd519af0c289e272b842c9cd95 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 01:41:04 +0900 Subject: [PATCH 002/118] Remove test script `r5rs-identifiers.ss` --- README.md | 6 +- VERSION | 2 +- test/r5rs-identifiers.ss | 249 --------------------------------------- 3 files changed, 4 insertions(+), 253 deletions(-) delete mode 100644 test/r5rs-identifiers.ss diff --git a/README.md b/README.md index 48774046e..abe53abbc 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.822.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.823.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.822_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.823_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.822 +Meevax Lisp System, version 0.3.823 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 2d69fdbf2..0ffbdd0cf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.822 +0.3.823 diff --git a/test/r5rs-identifiers.ss b/test/r5rs-identifiers.ss deleted file mode 100644 index 31e48e803..000000000 --- a/test/r5rs-identifiers.ss +++ /dev/null @@ -1,249 +0,0 @@ -; * + - ... / < <= = => > >= abs acos and angle append apply asin assoc assq -; assv atan begin boolean? caaaar caaadr caaar caadar caaddr caadr caar cadaar -; cadadr cadar caddar cadddr caddr cadr call-with-current-continuation -; call-with-input-file call-with-output-file call-with-values car case cdaaar -; cdaadr cdaar cdadar cdaddr cdadr cdar cddaar cddadr cddar cdddar cddddr cdddr -; cddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? -; char-upcase char-upper-case? char-whitespace? char<=? char=? -; char>? char? close-input-port close-output-port complex? cond cons cos -; current-input-port current-output-port define define-syntax delay denominator -; display do dynamic-wind else eof-object? eq? equal? eqv? eval even? -; exact->inexact exact? exp expt floor for-each force gcd if imag-part -; inexact->exact inexact? input-port? integer->char integer? -; interaction-environment lambda lcm length let let* let-syntax letrec -; letrec-syntax list list->string list->vector list-ref list-tail list? load log -; magnitude make-polar make-rectangular make-string make-vector map max member -; memq memv min modulo negative? newline not null-environment null? -; number->string number? numerator odd? open-input-file open-output-file or -; output-port? pair? peek-char positive? procedure? quasiquote quote quotient -; rational? rationalize read read-char real-part real? remainder reverse round -; scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list -; string->number string->symbol string-append string-ci<=? string-ci=? string-ci>? string-copy string-fill! string-length -; string-ref string-set! string<=? string=? string>? string? -; substring symbol->string symbol? syntax-rules tan truncate values vector -; vector->list vector-fill! vector-length vector-ref vector-set! vector? -; with-input-from-file with-output-to-file write write-char zero? - -* -+ -- -... -/ -< -<= -= -=> -> ->= -abs -acos -and -angle -append -apply -asin -assoc -assq -assv -atan -begin -boolean? -caaaar -caaadr -caaar -caadar -caaddr -caadr -caar -cadaar -cadadr -cadar -caddar -cadddr -caddr -cadr -call-with-current-continuation -call-with-input-file -call-with-output-file -call-with-values -car -case -cdaaar -cdaadr -cdaar -cdadar -cdaddr -cdadr -cdar -cddaar -cddadr -cddar -cdddar -cddddr -cdddr -cddr -cdr -ceiling -char->integer -char-alphabetic? -char-ci<=? -char-ci=? -char-ci>? -char-downcase -char-lower-case? -char-numeric? -char-ready? -char-upcase -char-upper-case? -char-whitespace? -char<=? -char=? -char>? -char? -close-input-port -close-output-port -complex? -cond -cons -cos -current-input-port -current-output-port -define -define-syntax -delay -denominator -display -do -dynamic-wind -else -eof-object? -eq? -equal? -eqv? -eval -even? -exact->inexact -exact? -exp -expt -floor -for-each -force -gcd -if -imag-part -inexact->exact -inexact? -input-port? -integer->char -integer? -interaction-environment -lambda -lcm -length -let -let* -let-syntax -letrec -letrec-syntax -list -list->string -list->vector -list-ref -list-tail -list? -load -log -magnitude -make-polar -make-rectangular -make-string -make-vector -map -max -member -memq -memv -min -modulo -negative? -newline -not -null-environment -null? -number->string -number? -numerator -odd? -open-input-file -open-output-file -or -output-port? -pair? -peek-char -positive? -procedure? -quasiquote -quote -quotient -rational? -rationalize -read -read-char -real-part -real? -remainder -reverse -round -scheme-report-environment -set! -set-car! -set-cdr! -sin -sqrt -string -string->list -string->number -string->symbol -string-append -string-ci<=? -string-ci=? -string-ci>? -string-copy -string-fill! -string-length -string-ref -string-set! -string<=? -string=? -string>? -string? -substring -symbol->string -symbol? -syntax-rules -tan -truncate -values -vector -vector->list -vector-fill! -vector-length -vector-ref -vector-set! -vector? -with-input-from-file -with-output-to-file -write -write-char -zero? From a38573346e80477898a85bda3cc788e55d3f014b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 01:51:26 +0900 Subject: [PATCH 003/118] Update copyright notice --- README.md | 6 +++--- VERSION | 2 +- configure/version.cpp | 2 +- include/meevax/algorithm/for_each.hpp | 2 +- include/meevax/functional/arithmetic_operation.hpp | 2 +- include/meevax/functional/combinator.hpp | 2 +- include/meevax/functional/compose.hpp | 2 +- include/meevax/functional/curry.hpp | 2 +- include/meevax/functional/decrementation.hpp | 2 +- include/meevax/functional/identity.hpp | 2 +- include/meevax/iostream/combinator.hpp | 2 +- include/meevax/iostream/escape_sequence.hpp | 2 +- include/meevax/iostream/ignore.hpp | 2 +- include/meevax/iostream/is_console.hpp | 2 +- include/meevax/iostream/lexical_cast.hpp | 2 +- include/meevax/iostream/putback.hpp | 2 +- include/meevax/iostream/write.hpp | 2 +- include/meevax/kernel/basis.hpp | 2 +- include/meevax/kernel/boolean.hpp | 2 +- include/meevax/kernel/character.hpp | 2 +- include/meevax/kernel/closure.hpp | 2 +- include/meevax/kernel/complex.hpp | 2 +- include/meevax/kernel/configurator.hpp | 2 +- include/meevax/kernel/constant.hpp | 2 +- include/meevax/kernel/context.hpp | 2 +- include/meevax/kernel/continuation.hpp | 2 +- include/meevax/kernel/environment.hpp | 2 +- include/meevax/kernel/equivalence.hpp | 2 +- include/meevax/kernel/error.hpp | 2 +- include/meevax/kernel/exact_integer.hpp | 2 +- include/meevax/kernel/floating_point.hpp | 2 +- include/meevax/kernel/ghost.hpp | 2 +- include/meevax/kernel/heterogeneous.hpp | 2 +- include/meevax/kernel/identifier.hpp | 2 +- include/meevax/kernel/instruction.hpp | 2 +- include/meevax/kernel/iterator.hpp | 2 +- include/meevax/kernel/list.hpp | 2 +- include/meevax/kernel/machine.hpp | 2 +- include/meevax/kernel/miscellaneous.hpp | 2 +- include/meevax/kernel/number.hpp | 2 +- include/meevax/kernel/object.hpp | 2 +- include/meevax/kernel/option.hpp | 2 +- include/meevax/kernel/overview.hpp | 2 +- include/meevax/kernel/pair.hpp | 2 +- include/meevax/kernel/port.hpp | 2 +- include/meevax/kernel/procedure.hpp | 2 +- include/meevax/kernel/profiler.hpp | 2 +- include/meevax/kernel/ratio.hpp | 2 +- include/meevax/kernel/reader.hpp | 2 +- include/meevax/kernel/stack.hpp | 2 +- include/meevax/kernel/string.hpp | 2 +- include/meevax/kernel/symbol.hpp | 2 +- include/meevax/kernel/syntactic_continuation.hpp | 2 +- include/meevax/kernel/syntactic_procedure.hpp | 2 +- include/meevax/kernel/syntax.hpp | 2 +- include/meevax/kernel/vector.hpp | 2 +- include/meevax/kernel/version.hpp | 2 +- include/meevax/kernel/writer.hpp | 2 +- include/meevax/memory/collector.hpp | 2 +- include/meevax/memory/deallocator.hpp | 2 +- include/meevax/memory/gc_pointer.hpp | 2 +- include/meevax/memory/literal.hpp | 2 +- include/meevax/memory/marker.hpp | 2 +- include/meevax/memory/region.hpp | 2 +- include/meevax/memory/simple_allocator.hpp | 2 +- include/meevax/memory/simple_pointer.hpp | 2 +- include/meevax/memory/tagged_pointer.hpp | 2 +- include/meevax/parser/class.hpp | 2 +- include/meevax/parser/combinator.hpp | 2 +- include/meevax/posix/noncanonical.hpp | 2 +- include/meevax/protocol/accessor.hpp | 2 +- include/meevax/protocol/connection.hpp | 2 +- include/meevax/protocol/event.hpp | 2 +- include/meevax/protocol/identity.hpp | 2 +- include/meevax/protocol/machine.hpp | 2 +- include/meevax/string/header.hpp | 2 +- include/meevax/string/repeat.hpp | 2 +- include/meevax/type_traits/is_equality_comparable.hpp | 2 +- include/meevax/type_traits/is_reference_wrapper.hpp | 2 +- include/meevax/type_traits/is_scoped_enum.hpp | 2 +- include/meevax/type_traits/requires.hpp | 2 +- include/meevax/type_traits/underlying_cast.hpp | 2 +- include/meevax/utility/construct_on_first_use.hpp | 2 +- include/meevax/utility/debug.hpp | 2 +- include/meevax/utility/demangle.hpp | 2 +- include/meevax/utility/description.hpp | 2 +- include/meevax/utility/enumeration.hpp | 2 +- include/meevax/utility/forward.hpp | 2 +- include/meevax/utility/hexdump.hpp | 2 +- include/meevax/utility/integer_sequence.hpp | 2 +- include/meevax/utility/module.hpp | 2 +- include/meevax/utility/overload.hpp | 2 +- include/meevax/utility/perfect_forward.hpp | 2 +- include/meevax/utility/unwrap_reference_wrapper.hpp | 2 +- include/meevax/visual/behavior.hpp | 2 +- include/meevax/visual/context.hpp | 2 +- include/meevax/visual/geometry.hpp | 2 +- include/meevax/visual/surface.hpp | 2 +- src/functional/arithmetic_operation.cpp | 2 +- src/iostream/putback.cpp | 2 +- src/kernel/basis.cpp | 2 +- src/kernel/boolean.cpp | 2 +- src/kernel/character.cpp | 2 +- src/kernel/closure.cpp | 2 +- src/kernel/complex.cpp | 2 +- src/kernel/constant.cpp | 2 +- src/kernel/continuation.cpp | 2 +- src/kernel/environment.cpp | 2 +- src/kernel/equivalence.cpp | 2 +- src/kernel/error.cpp | 2 +- src/kernel/exact_integer.cpp | 2 +- src/kernel/ghost.cpp | 2 +- src/kernel/identifier.cpp | 2 +- src/kernel/instruction.cpp | 2 +- src/kernel/iterator.cpp | 2 +- src/kernel/list.cpp | 2 +- src/kernel/miscellaneous.cpp | 2 +- src/kernel/number.cpp | 2 +- src/kernel/pair.cpp | 2 +- src/kernel/port.cpp | 2 +- src/kernel/procedure.cpp | 2 +- src/kernel/profiler.cpp | 2 +- src/kernel/ratio.cpp | 2 +- src/kernel/reader.cpp | 2 +- src/kernel/string.cpp | 2 +- src/kernel/symbol.cpp | 2 +- src/kernel/syntactic_continuation.cpp | 2 +- src/kernel/syntactic_procedure.cpp | 2 +- src/kernel/syntax.cpp | 2 +- src/kernel/vector.cpp | 2 +- src/library/meevax.cpp | 2 +- src/main.cpp | 2 +- src/memory/collector.cpp | 2 +- src/memory/marker.cpp | 2 +- src/memory/region.cpp | 2 +- src/string/header.cpp | 2 +- src/utility/demangle.cpp | 2 +- 137 files changed, 139 insertions(+), 139 deletions(-) diff --git a/README.md b/README.md index abe53abbc..c7aef3cee 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.823.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.824.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.823_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.824_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.823 +Meevax Lisp System, version 0.3.824 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 0ffbdd0cf..3f0d6721b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.823 +0.3.824 diff --git a/configure/version.cpp b/configure/version.cpp index cb29679ff..9cb1d7bb5 100644 --- a/configure/version.cpp +++ b/configure/version.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/algorithm/for_each.hpp b/include/meevax/algorithm/for_each.hpp index 4e7058dca..0505628d3 100644 --- a/include/meevax/algorithm/for_each.hpp +++ b/include/meevax/algorithm/for_each.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/arithmetic_operation.hpp b/include/meevax/functional/arithmetic_operation.hpp index e40b15c88..7dad5ec58 100644 --- a/include/meevax/functional/arithmetic_operation.hpp +++ b/include/meevax/functional/arithmetic_operation.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/combinator.hpp b/include/meevax/functional/combinator.hpp index 7b9cfc7c9..7d77e63a3 100644 --- a/include/meevax/functional/combinator.hpp +++ b/include/meevax/functional/combinator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/compose.hpp b/include/meevax/functional/compose.hpp index d1dec581e..187866047 100644 --- a/include/meevax/functional/compose.hpp +++ b/include/meevax/functional/compose.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/curry.hpp b/include/meevax/functional/curry.hpp index 9367e855c..6de1b6f13 100644 --- a/include/meevax/functional/curry.hpp +++ b/include/meevax/functional/curry.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/decrementation.hpp b/include/meevax/functional/decrementation.hpp index 9aa9921da..36bb10135 100644 --- a/include/meevax/functional/decrementation.hpp +++ b/include/meevax/functional/decrementation.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/functional/identity.hpp b/include/meevax/functional/identity.hpp index e679aebee..5f3b54d5d 100644 --- a/include/meevax/functional/identity.hpp +++ b/include/meevax/functional/identity.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/combinator.hpp b/include/meevax/iostream/combinator.hpp index d0f55fa0c..10210954b 100644 --- a/include/meevax/iostream/combinator.hpp +++ b/include/meevax/iostream/combinator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/escape_sequence.hpp b/include/meevax/iostream/escape_sequence.hpp index ef273b03e..549e9570e 100644 --- a/include/meevax/iostream/escape_sequence.hpp +++ b/include/meevax/iostream/escape_sequence.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/ignore.hpp b/include/meevax/iostream/ignore.hpp index 7a9e6fc20..5170f93bd 100644 --- a/include/meevax/iostream/ignore.hpp +++ b/include/meevax/iostream/ignore.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/is_console.hpp b/include/meevax/iostream/is_console.hpp index 031c82115..5fc098161 100644 --- a/include/meevax/iostream/is_console.hpp +++ b/include/meevax/iostream/is_console.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/lexical_cast.hpp b/include/meevax/iostream/lexical_cast.hpp index 64d444813..654a364e1 100644 --- a/include/meevax/iostream/lexical_cast.hpp +++ b/include/meevax/iostream/lexical_cast.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/putback.hpp b/include/meevax/iostream/putback.hpp index 197fc1373..8eb6fbf47 100644 --- a/include/meevax/iostream/putback.hpp +++ b/include/meevax/iostream/putback.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/iostream/write.hpp b/include/meevax/iostream/write.hpp index 030c9a62f..64ba9055b 100644 --- a/include/meevax/iostream/write.hpp +++ b/include/meevax/iostream/write.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/basis.hpp b/include/meevax/kernel/basis.hpp index 3308b9cb9..441de6cc7 100644 --- a/include/meevax/kernel/basis.hpp +++ b/include/meevax/kernel/basis.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/boolean.hpp b/include/meevax/kernel/boolean.hpp index 86d9e388f..798df6273 100644 --- a/include/meevax/kernel/boolean.hpp +++ b/include/meevax/kernel/boolean.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/character.hpp b/include/meevax/kernel/character.hpp index c45436922..6d6d05cdb 100644 --- a/include/meevax/kernel/character.hpp +++ b/include/meevax/kernel/character.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/closure.hpp b/include/meevax/kernel/closure.hpp index bfd855318..cf758e279 100644 --- a/include/meevax/kernel/closure.hpp +++ b/include/meevax/kernel/closure.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/complex.hpp b/include/meevax/kernel/complex.hpp index 5ca5f1907..cdee99b2f 100644 --- a/include/meevax/kernel/complex.hpp +++ b/include/meevax/kernel/complex.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index 7301c35c1..73269929d 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/constant.hpp b/include/meevax/kernel/constant.hpp index 7131b91ba..4e18431e3 100644 --- a/include/meevax/kernel/constant.hpp +++ b/include/meevax/kernel/constant.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/context.hpp b/include/meevax/kernel/context.hpp index 5c9ca91ed..98c633a42 100644 --- a/include/meevax/kernel/context.hpp +++ b/include/meevax/kernel/context.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/continuation.hpp b/include/meevax/kernel/continuation.hpp index 98d46815d..803309583 100644 --- a/include/meevax/kernel/continuation.hpp +++ b/include/meevax/kernel/continuation.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index cbb2e0caf..631e5f769 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/equivalence.hpp b/include/meevax/kernel/equivalence.hpp index d22d92cd4..7bbf8319c 100644 --- a/include/meevax/kernel/equivalence.hpp +++ b/include/meevax/kernel/equivalence.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/error.hpp b/include/meevax/kernel/error.hpp index 11f335bd8..0442e3917 100644 --- a/include/meevax/kernel/error.hpp +++ b/include/meevax/kernel/error.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/exact_integer.hpp b/include/meevax/kernel/exact_integer.hpp index 9b7d45a1c..d5bb40f0f 100644 --- a/include/meevax/kernel/exact_integer.hpp +++ b/include/meevax/kernel/exact_integer.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/floating_point.hpp b/include/meevax/kernel/floating_point.hpp index 14b51999c..e0d870e81 100644 --- a/include/meevax/kernel/floating_point.hpp +++ b/include/meevax/kernel/floating_point.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/ghost.hpp b/include/meevax/kernel/ghost.hpp index 39ab668e8..971abc64b 100644 --- a/include/meevax/kernel/ghost.hpp +++ b/include/meevax/kernel/ghost.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/heterogeneous.hpp b/include/meevax/kernel/heterogeneous.hpp index 9f7f00877..d362f4a44 100644 --- a/include/meevax/kernel/heterogeneous.hpp +++ b/include/meevax/kernel/heterogeneous.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 6e70b174a..9bdbcf691 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/instruction.hpp b/include/meevax/kernel/instruction.hpp index 31342e5ee..666f2dc9d 100644 --- a/include/meevax/kernel/instruction.hpp +++ b/include/meevax/kernel/instruction.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/iterator.hpp b/include/meevax/kernel/iterator.hpp index a069f5ffe..6b99f0dca 100644 --- a/include/meevax/kernel/iterator.hpp +++ b/include/meevax/kernel/iterator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index 430fa316f..833418db7 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index d3ad7511c..ebde10e3c 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/miscellaneous.hpp b/include/meevax/kernel/miscellaneous.hpp index bb30c83f8..34754bdb7 100644 --- a/include/meevax/kernel/miscellaneous.hpp +++ b/include/meevax/kernel/miscellaneous.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/number.hpp b/include/meevax/kernel/number.hpp index 58e74efcb..b23e75172 100644 --- a/include/meevax/kernel/number.hpp +++ b/include/meevax/kernel/number.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/object.hpp b/include/meevax/kernel/object.hpp index 67d914091..da08e4104 100644 --- a/include/meevax/kernel/object.hpp +++ b/include/meevax/kernel/object.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/option.hpp b/include/meevax/kernel/option.hpp index e06434b7f..a48b6a7d7 100644 --- a/include/meevax/kernel/option.hpp +++ b/include/meevax/kernel/option.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/overview.hpp b/include/meevax/kernel/overview.hpp index d0b99f7db..e6d398b10 100644 --- a/include/meevax/kernel/overview.hpp +++ b/include/meevax/kernel/overview.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/pair.hpp b/include/meevax/kernel/pair.hpp index ae94a76fb..efbea97ee 100644 --- a/include/meevax/kernel/pair.hpp +++ b/include/meevax/kernel/pair.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/port.hpp b/include/meevax/kernel/port.hpp index 57507cd9c..f9b9a8b50 100644 --- a/include/meevax/kernel/port.hpp +++ b/include/meevax/kernel/port.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index 766ff6276..755dc8496 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/profiler.hpp b/include/meevax/kernel/profiler.hpp index b4f2afac3..2622e0bd7 100644 --- a/include/meevax/kernel/profiler.hpp +++ b/include/meevax/kernel/profiler.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/ratio.hpp b/include/meevax/kernel/ratio.hpp index c557d7a27..57d7f16d4 100644 --- a/include/meevax/kernel/ratio.hpp +++ b/include/meevax/kernel/ratio.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/reader.hpp b/include/meevax/kernel/reader.hpp index 8d6ecc126..9599b5195 100644 --- a/include/meevax/kernel/reader.hpp +++ b/include/meevax/kernel/reader.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/stack.hpp b/include/meevax/kernel/stack.hpp index e3232cb7d..65c1191a3 100644 --- a/include/meevax/kernel/stack.hpp +++ b/include/meevax/kernel/stack.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/string.hpp b/include/meevax/kernel/string.hpp index c215fa132..374f91dca 100644 --- a/include/meevax/kernel/string.hpp +++ b/include/meevax/kernel/string.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/symbol.hpp b/include/meevax/kernel/symbol.hpp index 63ab6bcfd..4381e78c7 100644 --- a/include/meevax/kernel/symbol.hpp +++ b/include/meevax/kernel/symbol.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/syntactic_continuation.hpp b/include/meevax/kernel/syntactic_continuation.hpp index 09b0152be..172af2640 100644 --- a/include/meevax/kernel/syntactic_continuation.hpp +++ b/include/meevax/kernel/syntactic_continuation.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/syntactic_procedure.hpp b/include/meevax/kernel/syntactic_procedure.hpp index 6071fbd3f..099b588e5 100644 --- a/include/meevax/kernel/syntactic_procedure.hpp +++ b/include/meevax/kernel/syntactic_procedure.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/syntax.hpp b/include/meevax/kernel/syntax.hpp index aa67716e8..aabce807d 100644 --- a/include/meevax/kernel/syntax.hpp +++ b/include/meevax/kernel/syntax.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/vector.hpp b/include/meevax/kernel/vector.hpp index d9c623f71..2239d5945 100644 --- a/include/meevax/kernel/vector.hpp +++ b/include/meevax/kernel/vector.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/version.hpp b/include/meevax/kernel/version.hpp index fe588b48a..e885969d3 100644 --- a/include/meevax/kernel/version.hpp +++ b/include/meevax/kernel/version.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/kernel/writer.hpp b/include/meevax/kernel/writer.hpp index a7f21a96c..b326bbbb0 100644 --- a/include/meevax/kernel/writer.hpp +++ b/include/meevax/kernel/writer.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/collector.hpp b/include/meevax/memory/collector.hpp index 2f95d1d58..cedbbe07c 100644 --- a/include/meevax/memory/collector.hpp +++ b/include/meevax/memory/collector.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/deallocator.hpp b/include/meevax/memory/deallocator.hpp index 77431af8c..c7984db38 100644 --- a/include/meevax/memory/deallocator.hpp +++ b/include/meevax/memory/deallocator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/gc_pointer.hpp b/include/meevax/memory/gc_pointer.hpp index 8ed10776c..1ba7d2f34 100644 --- a/include/meevax/memory/gc_pointer.hpp +++ b/include/meevax/memory/gc_pointer.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/literal.hpp b/include/meevax/memory/literal.hpp index 99dc0ab89..0d89cdc96 100644 --- a/include/meevax/memory/literal.hpp +++ b/include/meevax/memory/literal.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/marker.hpp b/include/meevax/memory/marker.hpp index 3efa8e248..d3e7ac28b 100644 --- a/include/meevax/memory/marker.hpp +++ b/include/meevax/memory/marker.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/region.hpp b/include/meevax/memory/region.hpp index 4078df8d9..37bf02082 100644 --- a/include/meevax/memory/region.hpp +++ b/include/meevax/memory/region.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/simple_allocator.hpp b/include/meevax/memory/simple_allocator.hpp index 46fcef7aa..888cb1be5 100644 --- a/include/meevax/memory/simple_allocator.hpp +++ b/include/meevax/memory/simple_allocator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/simple_pointer.hpp b/include/meevax/memory/simple_pointer.hpp index 8d7d4ddfd..6688c84c9 100644 --- a/include/meevax/memory/simple_pointer.hpp +++ b/include/meevax/memory/simple_pointer.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/memory/tagged_pointer.hpp b/include/meevax/memory/tagged_pointer.hpp index ac83ae9eb..4204eb8c9 100644 --- a/include/meevax/memory/tagged_pointer.hpp +++ b/include/meevax/memory/tagged_pointer.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/parser/class.hpp b/include/meevax/parser/class.hpp index 3e444873c..a7fab4d44 100644 --- a/include/meevax/parser/class.hpp +++ b/include/meevax/parser/class.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/parser/combinator.hpp b/include/meevax/parser/combinator.hpp index a19e09bb3..6664e661e 100644 --- a/include/meevax/parser/combinator.hpp +++ b/include/meevax/parser/combinator.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/posix/noncanonical.hpp b/include/meevax/posix/noncanonical.hpp index b605452e7..c8d371fc2 100644 --- a/include/meevax/posix/noncanonical.hpp +++ b/include/meevax/posix/noncanonical.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/protocol/accessor.hpp b/include/meevax/protocol/accessor.hpp index 3d16638d9..1475eb6f0 100644 --- a/include/meevax/protocol/accessor.hpp +++ b/include/meevax/protocol/accessor.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/protocol/connection.hpp b/include/meevax/protocol/connection.hpp index 474967301..e101696ce 100644 --- a/include/meevax/protocol/connection.hpp +++ b/include/meevax/protocol/connection.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/protocol/event.hpp b/include/meevax/protocol/event.hpp index f46a8203a..b61bd87d7 100644 --- a/include/meevax/protocol/event.hpp +++ b/include/meevax/protocol/event.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/protocol/identity.hpp b/include/meevax/protocol/identity.hpp index 773319a7b..58faefcd6 100644 --- a/include/meevax/protocol/identity.hpp +++ b/include/meevax/protocol/identity.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/protocol/machine.hpp b/include/meevax/protocol/machine.hpp index c80df238d..e0bc9787d 100644 --- a/include/meevax/protocol/machine.hpp +++ b/include/meevax/protocol/machine.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/string/header.hpp b/include/meevax/string/header.hpp index e26f3545a..80cea9fce 100644 --- a/include/meevax/string/header.hpp +++ b/include/meevax/string/header.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/string/repeat.hpp b/include/meevax/string/repeat.hpp index 078dbe544..8e56d00ca 100644 --- a/include/meevax/string/repeat.hpp +++ b/include/meevax/string/repeat.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/type_traits/is_equality_comparable.hpp b/include/meevax/type_traits/is_equality_comparable.hpp index 6c676e0a8..8f30b9a9a 100644 --- a/include/meevax/type_traits/is_equality_comparable.hpp +++ b/include/meevax/type_traits/is_equality_comparable.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/type_traits/is_reference_wrapper.hpp b/include/meevax/type_traits/is_reference_wrapper.hpp index fcd2bf9d2..fa362769d 100644 --- a/include/meevax/type_traits/is_reference_wrapper.hpp +++ b/include/meevax/type_traits/is_reference_wrapper.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/type_traits/is_scoped_enum.hpp b/include/meevax/type_traits/is_scoped_enum.hpp index 21ae68cf7..c8060813c 100644 --- a/include/meevax/type_traits/is_scoped_enum.hpp +++ b/include/meevax/type_traits/is_scoped_enum.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/type_traits/requires.hpp b/include/meevax/type_traits/requires.hpp index 012b5055b..4fe291116 100644 --- a/include/meevax/type_traits/requires.hpp +++ b/include/meevax/type_traits/requires.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/type_traits/underlying_cast.hpp b/include/meevax/type_traits/underlying_cast.hpp index e781acec3..6e4f4bf2f 100644 --- a/include/meevax/type_traits/underlying_cast.hpp +++ b/include/meevax/type_traits/underlying_cast.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/construct_on_first_use.hpp b/include/meevax/utility/construct_on_first_use.hpp index 1dac20562..4d3adf446 100644 --- a/include/meevax/utility/construct_on_first_use.hpp +++ b/include/meevax/utility/construct_on_first_use.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/debug.hpp b/include/meevax/utility/debug.hpp index 455b3c115..d71a23a86 100644 --- a/include/meevax/utility/debug.hpp +++ b/include/meevax/utility/debug.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/demangle.hpp b/include/meevax/utility/demangle.hpp index 4452403c1..0f578b282 100644 --- a/include/meevax/utility/demangle.hpp +++ b/include/meevax/utility/demangle.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/description.hpp b/include/meevax/utility/description.hpp index 3f4cdbc6e..205c848ee 100644 --- a/include/meevax/utility/description.hpp +++ b/include/meevax/utility/description.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/enumeration.hpp b/include/meevax/utility/enumeration.hpp index 0002870f1..aa852199f 100644 --- a/include/meevax/utility/enumeration.hpp +++ b/include/meevax/utility/enumeration.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/forward.hpp b/include/meevax/utility/forward.hpp index d9c152007..f43f60410 100644 --- a/include/meevax/utility/forward.hpp +++ b/include/meevax/utility/forward.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/hexdump.hpp b/include/meevax/utility/hexdump.hpp index 47aa4e1e3..42ec19be5 100644 --- a/include/meevax/utility/hexdump.hpp +++ b/include/meevax/utility/hexdump.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/integer_sequence.hpp b/include/meevax/utility/integer_sequence.hpp index 919bed866..3436dd856 100644 --- a/include/meevax/utility/integer_sequence.hpp +++ b/include/meevax/utility/integer_sequence.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/module.hpp b/include/meevax/utility/module.hpp index 710256a74..6df353ad8 100644 --- a/include/meevax/utility/module.hpp +++ b/include/meevax/utility/module.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/overload.hpp b/include/meevax/utility/overload.hpp index ae302977a..9f7044c98 100644 --- a/include/meevax/utility/overload.hpp +++ b/include/meevax/utility/overload.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/perfect_forward.hpp b/include/meevax/utility/perfect_forward.hpp index ea3c6ea40..a3e36797c 100644 --- a/include/meevax/utility/perfect_forward.hpp +++ b/include/meevax/utility/perfect_forward.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/utility/unwrap_reference_wrapper.hpp b/include/meevax/utility/unwrap_reference_wrapper.hpp index 90db6250d..0c5355d4a 100644 --- a/include/meevax/utility/unwrap_reference_wrapper.hpp +++ b/include/meevax/utility/unwrap_reference_wrapper.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/visual/behavior.hpp b/include/meevax/visual/behavior.hpp index 3782225e9..1b6608787 100644 --- a/include/meevax/visual/behavior.hpp +++ b/include/meevax/visual/behavior.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/visual/context.hpp b/include/meevax/visual/context.hpp index 45f8611d9..f79037dbb 100644 --- a/include/meevax/visual/context.hpp +++ b/include/meevax/visual/context.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/visual/geometry.hpp b/include/meevax/visual/geometry.hpp index ed0978b0e..4e6e53263 100644 --- a/include/meevax/visual/geometry.hpp +++ b/include/meevax/visual/geometry.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/include/meevax/visual/surface.hpp b/include/meevax/visual/surface.hpp index f0cb1e809..616f716af 100644 --- a/include/meevax/visual/surface.hpp +++ b/include/meevax/visual/surface.hpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/functional/arithmetic_operation.cpp b/src/functional/arithmetic_operation.cpp index 9c051d6e2..82c17ed46 100644 --- a/src/functional/arithmetic_operation.cpp +++ b/src/functional/arithmetic_operation.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/iostream/putback.cpp b/src/iostream/putback.cpp index eaebe234b..b2d4533fa 100644 --- a/src/iostream/putback.cpp +++ b/src/iostream/putback.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/basis.cpp b/src/kernel/basis.cpp index 6526760fd..d63f4a7dc 100644 --- a/src/kernel/basis.cpp +++ b/src/kernel/basis.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/boolean.cpp b/src/kernel/boolean.cpp index 0f36584b9..31de59fdc 100644 --- a/src/kernel/boolean.cpp +++ b/src/kernel/boolean.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/character.cpp b/src/kernel/character.cpp index 6039122cb..75c2f32b6 100644 --- a/src/kernel/character.cpp +++ b/src/kernel/character.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/closure.cpp b/src/kernel/closure.cpp index 3e3adac41..5208a7511 100644 --- a/src/kernel/closure.cpp +++ b/src/kernel/closure.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/complex.cpp b/src/kernel/complex.cpp index 1de7923eb..003a4d771 100644 --- a/src/kernel/complex.cpp +++ b/src/kernel/complex.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/constant.cpp b/src/kernel/constant.cpp index 8572dea49..7969efa8a 100644 --- a/src/kernel/constant.cpp +++ b/src/kernel/constant.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/continuation.cpp b/src/kernel/continuation.cpp index 112afcdf8..3c7141d65 100644 --- a/src/kernel/continuation.cpp +++ b/src/kernel/continuation.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index f8c51fd48..ce504d93c 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/equivalence.cpp b/src/kernel/equivalence.cpp index a8591752e..da19399ca 100644 --- a/src/kernel/equivalence.cpp +++ b/src/kernel/equivalence.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/error.cpp b/src/kernel/error.cpp index e63523312..710c0ca5f 100644 --- a/src/kernel/error.cpp +++ b/src/kernel/error.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/exact_integer.cpp b/src/kernel/exact_integer.cpp index 809e37e96..afd5ea093 100644 --- a/src/kernel/exact_integer.cpp +++ b/src/kernel/exact_integer.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/ghost.cpp b/src/kernel/ghost.cpp index 2d47ae002..17a953a1a 100644 --- a/src/kernel/ghost.cpp +++ b/src/kernel/ghost.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 7870e3ab0..5549bb538 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 8fd783137..d131e49b2 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/iterator.cpp b/src/kernel/iterator.cpp index 9cee3462b..106f12cb0 100644 --- a/src/kernel/iterator.cpp +++ b/src/kernel/iterator.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/list.cpp b/src/kernel/list.cpp index d57b09fdc..fbd6e43ce 100644 --- a/src/kernel/list.cpp +++ b/src/kernel/list.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/miscellaneous.cpp b/src/kernel/miscellaneous.cpp index 62a2fd107..e9f189474 100644 --- a/src/kernel/miscellaneous.cpp +++ b/src/kernel/miscellaneous.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/number.cpp b/src/kernel/number.cpp index f349ee909..b4cb4a287 100644 --- a/src/kernel/number.cpp +++ b/src/kernel/number.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/pair.cpp b/src/kernel/pair.cpp index 8dba24f9c..547588507 100644 --- a/src/kernel/pair.cpp +++ b/src/kernel/pair.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/port.cpp b/src/kernel/port.cpp index cc0d8bafa..47abe9acc 100644 --- a/src/kernel/port.cpp +++ b/src/kernel/port.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/procedure.cpp b/src/kernel/procedure.cpp index 041e247d5..7821b9c67 100644 --- a/src/kernel/procedure.cpp +++ b/src/kernel/procedure.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/profiler.cpp b/src/kernel/profiler.cpp index 33214138c..d9a1bed04 100644 --- a/src/kernel/profiler.cpp +++ b/src/kernel/profiler.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/ratio.cpp b/src/kernel/ratio.cpp index 78d7fdea0..8d8d9311e 100644 --- a/src/kernel/ratio.cpp +++ b/src/kernel/ratio.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/reader.cpp b/src/kernel/reader.cpp index c4b28b8c8..dc06106e0 100644 --- a/src/kernel/reader.cpp +++ b/src/kernel/reader.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/string.cpp b/src/kernel/string.cpp index 9df5825fd..6149c11cd 100644 --- a/src/kernel/string.cpp +++ b/src/kernel/string.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/symbol.cpp b/src/kernel/symbol.cpp index dd0004da8..023b7694e 100644 --- a/src/kernel/symbol.cpp +++ b/src/kernel/symbol.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/syntactic_continuation.cpp b/src/kernel/syntactic_continuation.cpp index b5c7bfbf7..c4f2bd200 100644 --- a/src/kernel/syntactic_continuation.cpp +++ b/src/kernel/syntactic_continuation.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/syntactic_procedure.cpp b/src/kernel/syntactic_procedure.cpp index e51d163f6..bd4b7260e 100644 --- a/src/kernel/syntactic_procedure.cpp +++ b/src/kernel/syntactic_procedure.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/syntax.cpp b/src/kernel/syntax.cpp index 88089c468..9121c2171 100644 --- a/src/kernel/syntax.cpp +++ b/src/kernel/syntax.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/kernel/vector.cpp b/src/kernel/vector.cpp index dd7316cf5..337a5fe18 100644 --- a/src/kernel/vector.cpp +++ b/src/kernel/vector.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index afad4a81f..026abc32e 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/main.cpp b/src/main.cpp index 1b921921b..29ecdcdb2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/memory/collector.cpp b/src/memory/collector.cpp index 05913efc9..80a8997ec 100644 --- a/src/memory/collector.cpp +++ b/src/memory/collector.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/memory/marker.cpp b/src/memory/marker.cpp index dec05c7a3..1eba433f1 100644 --- a/src/memory/marker.cpp +++ b/src/memory/marker.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/memory/region.cpp b/src/memory/region.cpp index cbed333bc..49759d183 100644 --- a/src/memory/region.cpp +++ b/src/memory/region.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/string/header.cpp b/src/string/header.cpp index b8cc02621..87307dc37 100644 --- a/src/string/header.cpp +++ b/src/string/header.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/utility/demangle.cpp b/src/utility/demangle.cpp index 77a40756c..af31a51d2 100644 --- a/src/utility/demangle.cpp +++ b/src/utility/demangle.cpp @@ -1,5 +1,5 @@ /* - Copyright 2018-2021 Tatsuya Yamasaki. + Copyright 2018-2022 Tatsuya Yamasaki. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 8c6e3409b5249cabcddc68e8249144058d14bbf0 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 02:05:17 +0900 Subject: [PATCH 004/118] Simplify member function `heterogeneous::is` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/heterogeneous.hpp | 9 +-------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c7aef3cee..7ac9bfe01 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.824.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.825.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.824_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.825_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.824 +Meevax Lisp System, version 0.3.825 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 3f0d6721b..dc7bb3b5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.824 +0.3.825 diff --git a/include/meevax/kernel/heterogeneous.hpp b/include/meevax/kernel/heterogeneous.hpp index d362f4a44..9c7714f98 100644 --- a/include/meevax/kernel/heterogeneous.hpp +++ b/include/meevax/kernel/heterogeneous.hpp @@ -118,14 +118,7 @@ inline namespace kernel template inline auto is() const { - if constexpr (std::is_null_pointer::type>::value) - { - return not static_cast(*this); - } - else - { - return type() == typeid(typename std::decay::type); - } + return type() == typeid(typename std::decay::type); } template From a70837580d88bfc78803ffde77f3bb4e9496c189 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 02:21:45 +0900 Subject: [PATCH 005/118] Add new member function `transformer::build` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 16 +++++++++++----- src/kernel/environment.cpp | 1 - 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 7ac9bfe01..16e75508e 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.825.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.826.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.825_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.826_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.825 +Meevax Lisp System, version 0.3.826 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index dc7bb3b5e..c4f6b8e26 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.825 +0.3.826 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index ebde10e3c..970430893 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -67,16 +67,22 @@ inline namespace kernel * --------------------------------------------------------------------- */ : sk { spec().template as().c().template as() } { - auto const& k = spec().template as(); + spec() = build(spec().template as()); + environment::reset(); + } + + auto build(continuation const& k) -> object + { s = k.s(); e = k.e(); - c = compile(context::outermost, *this, sk.expression(), sk.frames()); + c = compile(context::outermost, + *this, + k.c().template as().expression(), + k.c().template as().frames()); d = k.d(); - spec() = environment::execute(); - - environment::reset(); + return environment::execute(); } auto macroexpand(const_reference keyword, const_reference form) /* ------- diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index ce504d93c..90d308641 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -257,7 +257,6 @@ inline namespace kernel auto operator <<(std::ostream & os, environment & datum) -> std::ostream & { - // TODO Evaluate datum.first, and write the evaluation to ostream. return datum.write(os, "environment::operator <<(std::ostream &, environment &)\n"); } From 89b716ba061e2be1242d79de9896af3677bf3a1f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 02:32:40 +0900 Subject: [PATCH 006/118] Remove member function `transformer::spec` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 21 ++++++--------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 16e75508e..ff52af54a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.826.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.827.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.826_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.827_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.826 +Meevax Lisp System, version 0.3.827 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index c4f6b8e26..393840ec0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.826 +0.3.827 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 970430893..345b21b87 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -56,6 +56,8 @@ inline namespace kernel syntactic_continuation const sk; + let const spec; + explicit transformer() /* ------------------------------------------------ * * Since the base class environment inherits from pair, all arguments @@ -65,10 +67,9 @@ inline namespace kernel * them. * * --------------------------------------------------------------------- */ - : sk { spec().template as().c().template as() } + : sk { environment::first.template as().c().template as() } + , spec { build(environment::first.template as()) } { - spec() = build(spec().template as()); - environment::reset(); } @@ -103,23 +104,13 @@ inline namespace kernel * --------------------------------------------------------------------- */ { d = cons(s, e, c, d); - c = spec().template as().c(); - e = cons(keyword, cdr(form)) | spec().template as().e(); + c = spec.template as().c(); + e = cons(keyword, cdr(form)) | spec.template as().e(); s = unit; return environment::execute(); } - auto spec() -> reference - { - return environment::first; - } - - auto spec() const -> const_reference - { - return environment::first; - } - friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & { return os << magenta("#,(") << green("fork/csc ") << datum.sk.expression() << magenta(")"); From 083090480195af00f10f21047bf86300045ee44b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 8 Feb 2022 23:54:10 +0900 Subject: [PATCH 007/118] Update `environment` to store local environment into `first` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 4 ++++ include/meevax/kernel/machine.hpp | 1 + src/kernel/environment.cpp | 12 +++++++++++- 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff52af54a..b350b1a74 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.827.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.828.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.827_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.828_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.827 +Meevax Lisp System, version 0.3.828 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 393840ec0..b8350870f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.827 +0.3.828 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 631e5f769..91e07ae95 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -90,6 +90,10 @@ inline namespace kernel auto load(const_reference) -> object; + auto local() const noexcept -> const_reference; + + auto local() noexcept -> reference; + auto rename(const_reference) -> const_reference; auto rename(const_reference, const_reference) -> object; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 345b21b87..6ae355ed8 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -70,6 +70,7 @@ inline namespace kernel : sk { environment::first.template as().c().template as() } , spec { build(environment::first.template as()) } { + environment::local() = sk.frames(); environment::reset(); } diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 90d308641..ee0a082e6 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -53,7 +53,7 @@ inline namespace kernel * ------------------------------------------------------------------------- */ { d = cons(s, e, c, d); - c = compile(context::none, *this, expression); + c = compile(context::none, *this, expression, local()); e = unit; s = unit; @@ -183,6 +183,16 @@ inline namespace kernel } } + auto environment::local() const noexcept -> const_reference + { + return first; + } + + auto environment::local() noexcept -> reference + { + return first; + } + auto environment::rename(const_reference variable) -> const_reference { if (let const& binding = assq(variable, global()); select(binding)) From ee054a24b5c1e7f340f1cab7a5ffa957cd95b90c Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 10 Feb 2022 00:00:53 +0900 Subject: [PATCH 008/118] Update test `er-macro-transformer` --- README.md | 6 ++--- VERSION | 2 +- test/abandoned.ss | 21 ----------------- test/er-macro-transformer.ss | 45 +++++++++++++++++++++++++++++++----- 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index b350b1a74..a47ffc485 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.828.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.829.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.828_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.829_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.828 +Meevax Lisp System, version 0.3.829 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b8350870f..b678059d0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.828 +0.3.829 diff --git a/test/abandoned.ss b/test/abandoned.ss index acaf70a50..82e7e119b 100644 --- a/test/abandoned.ss +++ b/test/abandoned.ss @@ -72,27 +72,6 @@ (let ((s "abcde")) (check (begin (string-fill! s #\x 1) s) => "axxxx")) (let ((s "abcde")) (check (begin (string-fill! s #\x 1 4) s) => "axxxe")) - -(define swap! - (fork/csc - (lambda (swap! x y) - (let ((z (string->symbol))) - `(,let ((,z ,x)) - (,set! ,x ,y) - (,set! ,y ,z)))))) - -(define swap! - (fork/csc - (lambda (swap! x y) - `(,let ((,value ,x)) - (,set! ,x ,y) - (,set! ,y ,value))))) - -(define-syntax (swap! x y) - `(,let ((,value ,x)) - (,set! ,x ,y) - (,set! ,y ,value))) - (define loop (fork/csc (lambda form diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index 4dafcd49e..2c837439e 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,10 +1,38 @@ -(define-syntax (er-macro-transformer expression) - (define (evaluate x) - (eval x er-macro-transformer)) - (define transform (evaluate expression)) +(define swap! (fork/csc - (lambda form - (transform form evaluate free-identifier=?)))) + (lambda (swap! x y) + `(,let ((,value ,x)) + (,set! ,x ,y) + (,set! ,y ,value))))) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +(swap! x y) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ + +(define-syntax (swap! x y) + `(,let ((,value ,x)) + (,set! ,x ,y) + (,set! ,y ,value))) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +(swap! x y) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ (define swap! (er-macro-transformer @@ -16,12 +44,17 @@ (,(rename 'set!) ,b ,(rename 'x))))))) (define x 1) + (define y 2) (check (cons x y) => (1 . 2)) + (swap! x y) + (check (cons x y) => (2 . 1)) +; ------------------------------------------------------------------------------ + (check-report) (exit (check-passed? check:correct)) From a53e1fb5594431322bcd5cd26bf39d845c69abf3 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 10 Feb 2022 21:04:56 +0900 Subject: [PATCH 009/118] Update syntax `define-syntax` to not to call syntax `define` --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 37 ++++++++++++++++++------------- test/er-macro-transformer.ss | 16 ++++++------- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index a47ffc485..1a607d827 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.829.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.830.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.829_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.830_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.829 +Meevax Lisp System, version 0.3.830 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b678059d0..1c00d0e73 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.829 +0.3.830 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 6ae355ed8..c1af2b212 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -70,7 +70,6 @@ inline namespace kernel : sk { environment::first.template as().c().template as() } , spec { build(environment::first.template as()) } { - environment::local() = sk.frames(); environment::reset(); } @@ -972,25 +971,31 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (car(expression).is()) // (define-syntax ( . xs) ) + if (frames.is() or (current_context & context::outermost)) { - return define(current_context, - current_environment, - list(caar(expression), - list(make("fork/csc", fork_csc), - cons(make("lambda", lambda), expression) - ) - ), - frames, - current_continuation); + if (car(expression).is()) // (define-syntax ( . ) ) + { + return compile(context::none, + current_environment, + list(make("fork/csc", fork_csc), + cons(make("lambda", lambda), expression)), + frames, + cons(make(mnemonic::define), current_environment.rename(caar(expression)), + current_continuation)); + } + else // (define-syntax x ...) + { + return compile(context::none, + current_environment, + cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), + frames, + cons(make(mnemonic::define), current_environment.rename(car(expression)), + current_continuation)); + } } else { - return define(current_context, - current_environment, - expression, - frames, - current_continuation); + throw syntax_error(make("definition cannot appear in this syntactic-context")); } } diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index 2c837439e..fc433dc24 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,9 +1,9 @@ (define swap! (fork/csc - (lambda (swap! x y) - `(,let ((,value ,x)) - (,set! ,x ,y) - (,set! ,y ,value))))) + (lambda (swap! a b) + `(,let ((,x ,a)) + (,set! ,a ,b) + (,set! ,b ,x))))) (define x 1) @@ -17,10 +17,10 @@ ; ------------------------------------------------------------------------------ -(define-syntax (swap! x y) - `(,let ((,value ,x)) - (,set! ,x ,y) - (,set! ,y ,value))) +(define-syntax (swap! a b) + `(,let ((,x ,a)) + (,set! ,a ,b) + (,set! ,b ,x))) (define x 1) From 24f7a9c353f8e4d34699692001722a414d80b937 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 10 Feb 2022 21:52:12 +0900 Subject: [PATCH 010/118] Update syntax `define-syntax` to set environment frame to given `transformer` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/instruction.hpp | 1 + include/meevax/kernel/machine.hpp | 26 ++++++++++++++++++++++++-- src/kernel/instruction.cpp | 2 ++ test/er-macro-transformer.ss | 4 ++-- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1a607d827..6beded6df 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.830.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.831.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.830_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.831_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.830 +Meevax Lisp System, version 0.3.831 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1c00d0e73..12a410e37 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.830 +0.3.831 diff --git a/include/meevax/kernel/instruction.hpp b/include/meevax/kernel/instruction.hpp index 666f2dc9d..8b795fb60 100644 --- a/include/meevax/kernel/instruction.hpp +++ b/include/meevax/kernel/instruction.hpp @@ -28,6 +28,7 @@ inline namespace kernel call, // a.k.a APP cons, // define, // + define_syntax, // drop, // dummy, // a.k.a DUM fork, // diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index c1af2b212..09e122e4d 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -401,6 +401,28 @@ inline namespace kernel c = cddr(c); goto decode; + case mnemonic::define_syntax: /* ----------------------------------------- + * + * ( . s) e (%define-syntax ( . ) . c) d => ( . s) e c d + * + * where = ( . x := ) + * + * ------------------------------------------------------------------- */ + [&]() + { + let const& frames = caadr(c); + + let const& identifier = cdadr(c); + + assert(car(s).template is()); + + identifier.as().binding() = car(s); + identifier.as().binding().as().local() = frames; + + c = cddr(c); + }(); + goto decode; + case mnemonic::let_syntax: /* -------------------------------------------- * * s e (%let_syntax . c) d => s e c' d @@ -980,7 +1002,7 @@ inline namespace kernel list(make("fork/csc", fork_csc), cons(make("lambda", lambda), expression)), frames, - cons(make(mnemonic::define), current_environment.rename(caar(expression)), + cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(caar(expression))), current_continuation)); } else // (define-syntax x ...) @@ -989,7 +1011,7 @@ inline namespace kernel current_environment, cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), frames, - cons(make(mnemonic::define), current_environment.rename(car(expression)), + cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(car(expression))), current_continuation)); } } diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index d131e49b2..c54e9b161 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -28,6 +28,7 @@ inline namespace kernel case mnemonic::call: return "call"; case mnemonic::cons: return "cons"; case mnemonic::define: return "define"; + case mnemonic::define_syntax: return "define-syntax"; case mnemonic::drop: return "drop"; case mnemonic::dummy: return "dummy"; case mnemonic::fork: return "fork"; @@ -102,6 +103,7 @@ inline namespace kernel break; case mnemonic::define: + case mnemonic::define_syntax: case mnemonic::fork: case mnemonic::let_syntax: case mnemonic::letrec_syntax: diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index fc433dc24..96da55efb 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,4 +1,4 @@ -(define swap! +(define-syntax swap! (fork/csc (lambda (swap! a b) `(,let ((,x ,a)) @@ -34,7 +34,7 @@ ; ------------------------------------------------------------------------------ -(define swap! +(define-syntax swap! (er-macro-transformer (lambda (form rename compare) (let ((a (cadr form)) From 1b928bd3059d83cf03098fdc566d613004969107 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 12 Feb 2022 22:23:19 +0900 Subject: [PATCH 011/118] Update syntax `let-syntax` to build `transformer`s --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 39 +++++++++++++++++++++++++------ test/let-syntax.ss | 31 +++++++++++++++++------- 4 files changed, 59 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 6beded6df..910de200d 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.831.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.832.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.831_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.832_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.831 +Meevax Lisp System, version 0.3.832 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 12a410e37..d31529ef3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.831 +0.3.832 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 09e122e4d..579521990 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -190,16 +190,11 @@ inline namespace kernel } else if (let const& identifier = std::as_const(current_environment).rename(car(expression), frames); identifier.is()) { - let & binding = identifier.as().binding(); - - if (not binding.is()) // DIRTY HACK - { - binding = environment(current_environment).execute(binding); - } + assert(identifier.as().binding().is()); return compile(context::none, current_environment, - binding.as().macroexpand(binding, expression), + identifier.as().binding().as().macroexpand(identifier.as().binding(), expression), frames, current_continuation); } @@ -428,6 +423,36 @@ inline namespace kernel * s e (%let_syntax . c) d => s e c' d * * ------------------------------------------------------------------- */ + [&]() + { + // PRINT(cadr(c).template is()); + + // let const& expression = cadr(c).template as().expression(); + // PRINT(expression); + + let const& frames = cadr(c).template as().frames(); + // PRINT(frames); + + // PRINT(car(frames)); + // PRINT(cdr(frames)); + + for (let const& keyword_ : car(frames)) + { + // PRINT(keyword_); + // PRINT(keyword_.is()); + + let & binding = keyword_.as().binding(); + + binding = environment(static_cast(*this)).execute(binding); + + // PRINT(binding.is()); + // PRINT(binding.as().spec); + // PRINT(binding.as().spec.template as().c()); + // PRINT(binding.as().spec.template as().e()); + // PRINT(binding.as().local().template is()); + } + }(); + std::swap(c.as(), body(context::none, static_cast(*this), diff --git a/test/let-syntax.ss b/test/let-syntax.ss index 760b816a8..ec305c7fb 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -15,20 +15,16 @@ `(,(rename '+) ,(cadr form) 3)))) (g (er-macro-transformer (lambda (form rename compare) - '()))) - ) + '())))) (set! result (cons (f 0) result)) - (let ((f (lambda (a) (+ a 4)))) - (set! result (cons (f 0) result)) - ))) - -; (display result) -; (newline) + (set! result (cons (f 0) result))))) (check result => (4 3 2 1)) +; ------------------------------------------------------------------------------ + (define y 100) (define (double-y) @@ -44,6 +40,25 @@ (check (double-y) => 201) +; ------------------------------------------------------------------------------ + +; (check (let ((x 'outer)) +; (let-syntax ((m (er-macro-transformer +; (lambda (form rename compare) +; (rename 'x))))) +; (let ((x 'inner)) +; (m)))) => outer) +; +; (define result +; (let ((x 'outer)) +; (let-syntax ((m (er-macro-transformer +; (lambda (form rename compare) +; (rename 'x))))) +; (let ((x 'inner)) +; (m))))) +; +; (check result => outer) + (check-report) (exit (check-passed? check:correct)) From 4317086c41e84897660a2eb255829438599a64cc Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Feb 2022 00:59:19 +0900 Subject: [PATCH 012/118] Update `transformer::macroexpand` to use instruction `call` --- README.md | 6 +-- VERSION | 2 +- include/meevax/kernel/machine.hpp | 73 ++++++++++++++++++++----------- src/main.cpp | 1 - 4 files changed, 52 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 910de200d..d4eb1046d 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.832.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.833.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.832_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.833_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.832 +Meevax Lisp System, version 0.3.833 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index d31529ef3..bde2c1a87 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.832 +0.3.833 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 579521990..204e9fae3 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -54,8 +54,6 @@ inline namespace kernel using environment::c; using environment::d; - syntactic_continuation const sk; - let const spec; explicit transformer() /* ------------------------------------------------ @@ -67,9 +65,10 @@ inline namespace kernel * them. * * --------------------------------------------------------------------- */ - : sk { environment::first.template as().c().template as() } - , spec { build(environment::first.template as()) } + : spec { build(environment::first.template as()) } { + assert(spec.template is()); + environment::reset(); } @@ -86,34 +85,58 @@ inline namespace kernel return environment::execute(); } - auto macroexpand(const_reference keyword, const_reference form) /* ------- + template + auto macroexpand(Ts&&... xs) /* ------------------------------------------ + * + * Scheme programs can define and use new derived expression types, + * called macros. Program-defined expression types have the syntax + * + * ( ...) + * + * where is an identifier that uniquely determines the + * expression type. This identifier is called the syntactic keyword, or + * simply keyword, of the macro. The number of the s, and their + * syntax, depends on the expression type. * - * is implemented as a closure. Since closure::c is - * terminated by the return instruction, it is necessary to put a stop + * Each instance of a macro is called a use of the macro. The set of + * rules that specifies how a use of a macro is transcribed into a more + * primitive expression is called the transformer of the macro. + * + * NOTE: is implemented as a closure. Since closure::c + * is terminated by the return instruction, it is necessary to put a stop * instruction in the dump register (this stop instruction is preset by * the constructor of the transformer). * - * transformer::macroexpand is never called recursively. This is because - * in the normal macro expansion performed by machine::compile, control - * is returned to machine::compile each time the macro is expanded one - * step. As an exception, there are cases where this transformer is given - * to the eval procedure as an , but there is no - * problem because the stack control at that time is performed by - * environment::evaluate. + * NOTE: transformer::macroexpand is never called recursively. This is + * because in the normal macro expansion performed by machine::compile, + * control is returned to machine::compile each time the macro is + * expanded one step. As an exception, there are cases where this + * transformer is given to the eval procedure as an + * , but there is no problem because the stack + * control at that time is performed by environment::evaluate. * * --------------------------------------------------------------------- */ { - d = cons(s, e, c, d); - c = spec.template as().c(); - e = cons(keyword, cdr(form)) | spec.template as().e(); - s = unit; + assert(spec.template is()); + + assert(d.template is()); + assert(c.template is()); + assert(e.template is()); + assert(s.template is()); + + assert(car(c).template is()); + assert(car(c).template as().value == mnemonic::stop); + assert(cdr(c).template is()); + + s = list(spec, cons(std::forward(xs)...)); + c = cons(make(mnemonic::call), c); return environment::execute(); } friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & { - return os << magenta("#,(") << green("fork/csc ") << datum.sk.expression() << magenta(")"); + return os << magenta("#,(") << green("fork/csc ") << faint("#;", &datum) << magenta(")"); } }; @@ -194,7 +217,7 @@ inline namespace kernel return compile(context::none, current_environment, - identifier.as().binding().as().macroexpand(identifier.as().binding(), expression), + identifier.as().binding().as().macroexpand(identifier.as().binding(), cdr(expression)), frames, current_continuation); } @@ -210,7 +233,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().macroexpand(applicant, expression), + applicant.as().macroexpand(applicant, cdr(expression)), frames, current_continuation); } @@ -501,8 +524,8 @@ inline namespace kernel * ------------------------------------------------------------------- */ { d = cons(cddr(s), e, cdr(c), d); - c = car(callee); - e = cons(cadr(s), cdr(callee)); + c = callee.as().c(); + e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- @@ -544,8 +567,8 @@ inline namespace kernel * * ------------------------------------------------------------------- */ { - c = car(callee); - e = cons(cadr(s), cdr(callee)); + c = callee.as().c(); + e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- diff --git a/src/main.cpp b/src/main.cpp index 29ecdcdb2..b6678d88c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -30,7 +30,6 @@ auto main(int const argc, char const* const* const argv) -> int if (main.is_interactive_mode()) { main.display_version(); - main.print(); main.print(features()); } From a7796b3277ed5318835365142d468c9899c672b6 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Feb 2022 22:23:04 +0900 Subject: [PATCH 013/118] Update option `--load` to not to accept `symbol` type --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 4 ++-- include/meevax/kernel/environment.hpp | 2 -- src/kernel/environment.cpp | 24 ------------------------ 5 files changed, 6 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index d4eb1046d..e02887494 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.833.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.834.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.833_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.834_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.833 +Meevax Lisp System, version 0.3.834 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index bde2c1a87..9a4912d41 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.833 +0.3.834 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index 73269929d..46d09e1a3 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -95,7 +95,7 @@ inline namespace kernel std::make_pair('l', [this](const_reference x) { - return load(x); + return load(x.as()); }), std::make_pair('w', [this](const_reference x) @@ -153,7 +153,7 @@ inline namespace kernel std::make_pair("load", [this](const_reference x) { - return load(x); + return load(x.as()); }), std::make_pair("prompt", [this](const_reference x) diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 91e07ae95..4ebfed5f9 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -88,8 +88,6 @@ inline namespace kernel auto load(std::string const&) -> object; - auto load(const_reference) -> object; - auto local() const noexcept -> const_reference; auto local() noexcept -> reference; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index ee0a082e6..d8730689c 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -144,16 +144,10 @@ inline namespace kernel auto environment::load(std::string const& s) -> object { - write(debug_port(), header(__func__), "open ", s, " => "); - if (let port = make(s); port and port.as().is_open()) { - write(debug_port(), t, "\n"); - for (let e = read(port); e != eof_object; e = read(port)) { - write(debug_port(), header(__func__), e, "\n"); - evaluate(e); } @@ -161,28 +155,10 @@ inline namespace kernel } else { - write(debug_port(), f, "\n"); - throw file_error(make("failed to open file: " + s)); } } - auto environment::load(const_reference x) -> object - { - if (x.is()) - { - return load(x.as()); - } - else if (x.is()) - { - return load(x.as()); - } - else - { - throw file_error(make(cat, __FILE__, ":", __LINE__, ":", __func__)); - } - } - auto environment::local() const noexcept -> const_reference { return first; From afb959465c215badb8429ca45da44b7aba9505d3 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Feb 2022 00:46:29 +0900 Subject: [PATCH 014/118] Update `iterator` base type to `object` from `std::reference_wrapper` PERFORMANCE HAS DEGRADED. --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/iterator.hpp | 8 ++------ include/meevax/kernel/list.hpp | 12 ++++++++---- src/kernel/identifier.cpp | 6 +++--- src/kernel/iterator.cpp | 27 +++++++-------------------- 6 files changed, 24 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index e02887494..03fed8377 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.834.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.835.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.834_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.835_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.834 +Meevax Lisp System, version 0.3.835 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9a4912d41..0fc90a4b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.834 +0.3.835 diff --git a/include/meevax/kernel/iterator.hpp b/include/meevax/kernel/iterator.hpp index 6b99f0dca..446d5d2c4 100644 --- a/include/meevax/kernel/iterator.hpp +++ b/include/meevax/kernel/iterator.hpp @@ -25,7 +25,7 @@ namespace meevax { inline namespace kernel { - struct iterator : public std::reference_wrapper + struct iterator : public object { using iterator_category = std::forward_iterator_tag; @@ -41,7 +41,7 @@ inline namespace kernel using size_type = std::size_t; - iterator(const_reference); + using object::object; auto operator *() const -> const_reference; @@ -50,10 +50,6 @@ inline namespace kernel auto operator ++() -> iterator &; auto operator ++(int) -> iterator; - - explicit operator bool() const; - - auto unwrap() const noexcept -> const_reference; }; auto operator ==(iterator const&, iterator const&) noexcept -> bool; diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index 833418db7..f649f7419 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -30,13 +30,17 @@ inline namespace kernel { auto unwrap = [](auto&& x) -> decltype(auto) { - using decayed_type = typename std::decay::type; + using type = typename std::decay::type; - if constexpr (std::is_same::value) + if constexpr (std::is_same::type, iterator>::value) { - return *x.unwrap(); + return *static_cast(x); } - else if constexpr (std::is_same::value) + else if constexpr (std::is_same::type, const iterator>::value) + { + return *static_cast(x); + } + else if constexpr (std::is_same::value) { return *x; } diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 5549bb538..af8e8aaff 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -70,19 +70,19 @@ inline namespace kernel { for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) { - if (inner.unwrap().is() and eq(*inner, variable)) + if (inner.is() and eq(*inner, variable)) { return make(variable, cons(make(std::distance(std::begin(frames), outer)), make(std::distance(std::begin(*outer), inner)))); } - else if (inner.unwrap().is() and eq(inner, variable)) + else if (inner.is() and eq(inner, variable)) { return make(variable, cons(make(std::distance(std::begin(frames), outer)), make(std::distance(std::begin(*outer), inner)))); } - else if (inner.unwrap().is() and (*inner).is() and eq((*inner).as().symbol(), variable)) + else if (inner.is() and (*inner).is() and eq((*inner).as().symbol(), variable)) { return *inner; } diff --git a/src/kernel/iterator.cpp b/src/kernel/iterator.cpp index 106f12cb0..50ce33339 100644 --- a/src/kernel/iterator.cpp +++ b/src/kernel/iterator.cpp @@ -20,10 +20,6 @@ namespace meevax { inline namespace kernel { - iterator::iterator(const_reference x) - : std::reference_wrapper { std::cref(x) } - {} - auto iterator::operator *() const -> iterator::const_reference { return car(*this); @@ -31,12 +27,13 @@ inline namespace kernel auto iterator::operator ->() const -> iterator::pointer { - return unwrap(); + return *this; } auto iterator::operator ++() -> iterator & { - return *this = cdr(*this); + static_cast(*this) = cdr(*this); + return *this; } auto iterator::operator ++(int) -> iterator @@ -46,16 +43,6 @@ inline namespace kernel return copy; } - iterator::operator bool() const - { - return static_cast(unwrap()); - } - - auto iterator::unwrap() const noexcept -> const_reference - { - return get(); - } - auto operator ==(iterator const& lhs, iterator const& rhs) noexcept -> bool { return lhs.get() == rhs.get(); @@ -72,12 +59,12 @@ namespace std { auto begin(meevax::const_reference x) -> meevax::iterator { - return cbegin(x); + return meevax::iterator(x); } auto cbegin(meevax::const_reference x) -> meevax::iterator { - return x; + return meevax::iterator(x); } auto cend(meevax::const_reference) -> meevax::iterator const& @@ -88,7 +75,7 @@ namespace std auto end(meevax::const_reference) -> meevax::iterator const& { - static meevax::iterator const cend { meevax::unit }; - return cend; + static meevax::iterator const end { meevax::unit }; + return end; } } // namespace std From ee586171065582fd31912137f0238a58e99fd026 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Feb 2022 01:08:36 +0900 Subject: [PATCH 015/118] Simplify helper function `unwrap` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/list.hpp | 14 ++++---------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 03fed8377..ae49b5b20 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.835.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.836.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.835_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.836_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.835 +Meevax Lisp System, version 0.3.836 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 0fc90a4b7..b875e7482 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.835 +0.3.836 diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index f649f7419..f706b4c42 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -30,19 +30,13 @@ inline namespace kernel { auto unwrap = [](auto&& x) -> decltype(auto) { + static_assert(std::is_convertible::value); + using type = typename std::decay::type; - if constexpr (std::is_same::type, iterator>::value) - { - return *static_cast(x); - } - else if constexpr (std::is_same::type, const iterator>::value) - { - return *static_cast(x); - } - else if constexpr (std::is_same::value) + if constexpr (std::is_convertible::value) { - return *x; + return x.template as(); } else { From 5f2ecf804449951dc335c24c656c3d5805ca7545 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Feb 2022 01:58:31 +0900 Subject: [PATCH 016/118] Fix `iterator::operator ->` to return correct value --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/iterator.hpp | 2 +- src/kernel/iterator.cpp | 2 +- test/list.cpp | 18 ++++++++++++++++++ 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index ae49b5b20..b415f82a0 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.836.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.837.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.836_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.837_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.836 +Meevax Lisp System, version 0.3.837 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b875e7482..58c3e60b7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.836 +0.3.837 diff --git a/include/meevax/kernel/iterator.hpp b/include/meevax/kernel/iterator.hpp index 446d5d2c4..23e6530e6 100644 --- a/include/meevax/kernel/iterator.hpp +++ b/include/meevax/kernel/iterator.hpp @@ -35,7 +35,7 @@ inline namespace kernel using const_reference = meevax::const_reference; - using pointer = meevax::const_reference; // homoiconicity + using pointer = typename std::add_pointer::type; using difference_type = std::ptrdiff_t; diff --git a/src/kernel/iterator.cpp b/src/kernel/iterator.cpp index 50ce33339..566877961 100644 --- a/src/kernel/iterator.cpp +++ b/src/kernel/iterator.cpp @@ -27,7 +27,7 @@ inline namespace kernel auto iterator::operator ->() const -> iterator::pointer { - return *this; + return std::addressof(car(*this)); } auto iterator::operator ++() -> iterator & diff --git a/test/list.cpp b/test/list.cpp index 1bd005001..1da9c62f2 100644 --- a/test/list.cpp +++ b/test/list.cpp @@ -38,5 +38,23 @@ auto main() -> int assert(caddr(x) == c); assert(cadddr(x) == a); + { + let x = list(a, b, c); + + for (auto iter = std::begin(x); iter != std::end(x); ++iter) + { + assert((*iter).template is()); + } + } + + { + let x = list(a, b, c); + + for (auto iter = std::begin(x); iter != std::end(x); ++iter) + { + assert(iter->template is()); + } + } + return EXIT_SUCCESS; } From f5834f4e0dc5996a902c1561f594e9b602af5db5 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Feb 2022 01:49:45 +0900 Subject: [PATCH 017/118] Update `CMakeLists.txt` to strip symbols from binaries Signed-off-by: yamacir-kit --- .github/workflows/build.yaml | 2 +- CMakeLists.txt | 11 ++++++----- README.md | 6 +++--- VERSION | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 136c68b9f..cb66aa34c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,7 @@ on: jobs: Ubuntu: runs-on: ${{ matrix.system }} - timeout-minutes: 120 + timeout-minutes: 180 env: CXX: ${{ matrix.compiler }} strategy: diff --git a/CMakeLists.txt b/CMakeLists.txt index c5b5e944d..11983e60d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,10 +88,10 @@ target_link_libraries(kernel PRIVATE stdc++fs PRIVATE ${CMAKE_DL_LIBS} PUBLIC gmp) -set_target_properties( - kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax - VERSION ${PROJECT_VERSION} - SOVERSION ${PROJECT_VERSION_MAJOR}) +set_target_properties(kernel PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename libkernel => libmeevax + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + LINK_FLAGS_RELEASE -s) # ---- Target shell ------------------------------------------------------------ @@ -99,7 +99,8 @@ add_executable(shell ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp) target_link_libraries(shell PRIVATE kernel) -set_target_properties(shell PROPERTIES OUTPUT_NAME ${PROJECT_NAME}) # Rename shell => meevax +set_target_properties(shell PROPERTIES OUTPUT_NAME ${PROJECT_NAME} # Rename shell => meevax + LINK_FLAGS_RELEASE -s) # ---- CMake Package ----------------------------------------------------------- diff --git a/README.md b/README.md index b415f82a0..bbf04a417 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.837.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.838.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.837_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.838_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.837 +Meevax Lisp System, version 0.3.838 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 58c3e60b7..a1b4fceb3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.837 +0.3.838 From 229a7abc375886b38eab0d3f3e2a36d94565d532 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Feb 2022 21:31:56 +0900 Subject: [PATCH 018/118] Update `environment::build` to receive `environment` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 29 +++++++++++++++-------------- test/let-syntax.ss | 8 ++++++++ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index bbf04a417..2812a62e4 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.838.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.840.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.838_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.840_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.838 +Meevax Lisp System, version 0.3.840 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a1b4fceb3..4a2171c64 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.838 +0.3.840 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 204e9fae3..7f483fe8b 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -54,7 +54,7 @@ inline namespace kernel using environment::c; using environment::d; - let const spec; + let spec; explicit transformer() /* ------------------------------------------------ * @@ -65,24 +65,24 @@ inline namespace kernel * them. * * --------------------------------------------------------------------- */ - : spec { build(environment::first.template as()) } + // : spec { build(environment::first.template as()) } { - assert(spec.template is()); + // assert(spec.template is()); environment::reset(); } - auto build(continuation const& k) -> object + auto build(environment const& base) -> object { - s = k.s(); - e = k.e(); + s = base.s; + e = base.e; c = compile(context::outermost, *this, - k.c().template as().expression(), - k.c().template as().frames()); - d = k.d(); + cadr(base.c).template as().expression(), + cadr(base.c).template as().frames()); + d = base.d; - return environment::execute(); + return spec = environment::execute(); } template @@ -373,7 +373,10 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - s = cons(make(make(s, e, cadr(c), d), global()), s); + // make(s, e, cadr(c), d), global() + s = cons(make(static_cast(*this)), s); + // car(s).template as().build(continuation(s, e, cadr(c), d)); + car(s).template as().build(static_cast(*this)); c = cddr(c); goto decode; @@ -428,14 +431,13 @@ inline namespace kernel * ------------------------------------------------------------------- */ [&]() { - let const& frames = caadr(c); + // let const& frames = caadr(c); let const& identifier = cdadr(c); assert(car(s).template is()); identifier.as().binding() = car(s); - identifier.as().binding().as().local() = frames; c = cddr(c); }(); @@ -472,7 +474,6 @@ inline namespace kernel // PRINT(binding.as().spec); // PRINT(binding.as().spec.template as().c()); // PRINT(binding.as().spec.template as().e()); - // PRINT(binding.as().local().template is()); } }(); diff --git a/test/let-syntax.ss b/test/let-syntax.ss index ec305c7fb..7785f25b7 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -42,6 +42,14 @@ ; ------------------------------------------------------------------------------ +; (check (let ((x 'outer)) +; (let-syntax ((m (fork/csc +; (lambda (this) x)))) +; (let ((x 'inner)) +; (m)))) => outer) + +; ------------------------------------------------------------------------------ + ; (check (let ((x 'outer)) ; (let-syntax ((m (er-macro-transformer ; (lambda (form rename compare) From 60687c10c94f40d5b155ef16b58e1ab532f0976e Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Feb 2022 22:01:34 +0900 Subject: [PATCH 019/118] Fix `transformer` to reset environment after build --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 17 +++++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2812a62e4..cb35e32c8 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.840.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.841.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.840_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.841_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.840 +Meevax Lisp System, version 0.3.841 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 4a2171c64..b1c130364 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.840 +0.3.841 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 7f483fe8b..07c706c65 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -40,6 +40,7 @@ inline namespace kernel {} IMPORT(environment, global, const); + IMPORT(environment, local, ); protected: let s, // stack (holding intermediate results and return address) @@ -69,10 +70,10 @@ inline namespace kernel { // assert(spec.template is()); - environment::reset(); + // environment::reset(); } - auto build(environment const& base) -> object + auto build(environment const& base) -> void { s = base.s; e = base.e; @@ -82,7 +83,9 @@ inline namespace kernel cadr(base.c).template as().frames()); d = base.d; - return spec = environment::execute(); + spec = environment::execute(); + + environment::reset(); } template @@ -119,6 +122,10 @@ inline namespace kernel { assert(spec.template is()); + PRINT(s); + PRINT(e); + PRINT(c); + PRINT(d); assert(d.template is()); assert(c.template is()); assert(e.template is()); @@ -373,9 +380,7 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - // make(s, e, cadr(c), d), global() - s = cons(make(static_cast(*this)), s); - // car(s).template as().build(continuation(s, e, cadr(c), d)); + s = cons(make(local(), global()), s); car(s).template as().build(static_cast(*this)); c = cddr(c); goto decode; From 621e07ddca038972c90b9cc46cd0827e47dab7e7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 20 Feb 2022 12:08:33 +0900 Subject: [PATCH 020/118] Update `procedure` to receive `environment` as 2nd argument --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 40 ++-- include/meevax/kernel/machine.hpp | 40 ++-- include/meevax/kernel/procedure.hpp | 4 +- src/kernel/environment.cpp | 14 +- src/kernel/instruction.cpp | 4 +- src/library/meevax.cpp | 278 ++++++++++++------------- test/vector.cpp | 4 +- 9 files changed, 194 insertions(+), 198 deletions(-) diff --git a/README.md b/README.md index cb35e32c8..648eb12ae 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.841.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.842.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.841_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.842_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.841 +Meevax Lisp System, version 0.3.842 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b1c130364..659514a65 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.841 +0.3.842 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index 46d09e1a3..e17d1f779 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -28,15 +28,15 @@ namespace meevax { inline namespace kernel { - template + template class configurator { - friend Environment; + friend environment; - IMPORT(Environment, evaluate, NIL); - IMPORT(Environment, load, NIL); - IMPORT(Environment, print, const); - IMPORT(Environment, read, NIL); + IMPORT(environment, evaluate, NIL); + IMPORT(environment, load, NIL); + IMPORT(environment, print, const); + IMPORT(environment, read, NIL); template using dispatcher = std::unordered_map; @@ -88,17 +88,17 @@ inline namespace kernel , short_options_with_arguments { - std::make_pair('e', [this](const_reference x) + std::make_pair('e', [this](const_reference x, auto &&) { return print(evaluate(x)), unspecified_object; }), - std::make_pair('l', [this](const_reference x) + std::make_pair('l', [this](const_reference x, auto &&) { return load(x.as()); }), - std::make_pair('w', [this](const_reference x) + std::make_pair('w', [this](const_reference x, auto &&) { return print(x), unspecified_object; }), @@ -146,22 +146,22 @@ inline namespace kernel , long_options_with_arguments { - std::make_pair("evaluate", [this](const_reference x) + std::make_pair("evaluate", [this](const_reference x, auto &&) { return print(evaluate(x)), unspecified_object; }), - std::make_pair("load", [this](const_reference x) + std::make_pair("load", [this](const_reference x, auto &&) { return load(x.as()); }), - std::make_pair("prompt", [this](const_reference x) + std::make_pair("prompt", [this](const_reference x, auto &&) { return prompt = x; }), - std::make_pair("write", [this](const_reference x) + std::make_pair("write", [this](const_reference x, auto &&) { return print(x), unspecified_object; }), @@ -204,11 +204,13 @@ inline namespace kernel { if (auto const& [name, perform] = *iter; std::next(current_short_option) != std::end(current_short_options)) { - return perform(read(std::string(std::next(current_short_option), std::end(current_short_options)))); + return perform(read(std::string(std::next(current_short_option), std::end(current_short_options))), + static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { - return perform(read(*current_option)); + return perform(read(*current_option), + static_cast(*this)); } else { @@ -217,7 +219,7 @@ inline namespace kernel } else if (auto iter = short_options.find(*current_short_option); iter != std::end(short_options)) { - cdr(*iter)(unit); + cdr(*iter)(unit, static_cast(*this)); } else { @@ -231,11 +233,11 @@ inline namespace kernel { if (analysis.length(2)) // argument part { - return cdr(*iter)(read(analysis.str(3))); + return cdr(*iter)(read(analysis.str(3)), static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { - return cdr(*iter)(read(*current_option)); + return cdr(*iter)(read(*current_option), static_cast(*this)); } else { @@ -244,7 +246,7 @@ inline namespace kernel } else if (auto iter = long_options.find(current_long_option); iter != std::end(long_options)) { - return cdr(*iter)(unit); + return cdr(*iter)(unit, static_cast(*this)); } else { diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 07c706c65..9a2573b4e 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -66,12 +66,7 @@ inline namespace kernel * them. * * --------------------------------------------------------------------- */ - // : spec { build(environment::first.template as()) } - { - // assert(spec.template is()); - - // environment::reset(); - } + {} auto build(environment const& base) -> void { @@ -122,10 +117,6 @@ inline namespace kernel { assert(spec.template is()); - PRINT(s); - PRINT(e); - PRINT(c); - PRINT(d); assert(d.template is()); assert(c.template is()); assert(e.template is()); @@ -136,7 +127,7 @@ inline namespace kernel assert(cdr(c).template is()); s = list(spec, cons(std::forward(xs)...)); - c = cons(make(mnemonic::call), c); + c = cons(make(mnemonic::call), environment::local(), c); return environment::execute(); } @@ -289,7 +280,7 @@ inline namespace kernel current_environment, car(expression), frames, - cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), + cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), frames, current_continuation))); } } @@ -523,27 +514,28 @@ inline namespace kernel case mnemonic::call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) + * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) * * where = (c' . e') * * ------------------------------------------------------------------- */ { - d = cons(cddr(s), e, cdr(c), d); + d = cons(cddr(s), e, cddr(c), d); c = callee.as().c(); e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = callee.as().apply(cadr(s)) | cddr(s); - c = cdr(c); + s = cons(callee.as().apply(cadr(s), static_cast(*this)), + cddr(s)); + c = cddr(c); } else if (callee.is()) /* --------------------------------- * @@ -567,7 +559,7 @@ inline namespace kernel case mnemonic::tail_call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d + * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d * * where = (c' . e') * @@ -579,18 +571,19 @@ inline namespace kernel } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = callee.as().apply(cadr(s)) | cddr(s); - c = cdr(c); + s = cons(callee.as().apply(cadr(s), static_cast(*this)), + cddr(s)); + c = cddr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -855,7 +848,8 @@ inline namespace kernel current_environment, car(expression), frames, - cons(make(mnemonic::call), current_continuation))); + cons(make(mnemonic::call), frames, + current_continuation))); } static SYNTAX(if_) /* ------------------------------------------------------ diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index 755dc8496..acfeb3e4a 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -24,7 +24,7 @@ namespace meevax { inline namespace kernel { - #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs) + #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs, environment &) struct procedure : public description { @@ -48,7 +48,7 @@ inline namespace kernel template struct is { - auto operator ()(const_reference xs) const -> const_reference + auto operator ()(const_reference xs, environment const&) const -> const_reference { auto is_T = [](const_reference x) { diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index d8730689c..c9621c167 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -101,7 +101,7 @@ inline namespace kernel auto environment::import() -> void { - define("free-identifier=?", [](let const& xs) + define("free-identifier=?", [](let const& xs, auto&&) { if (let const& a = car(xs); a.is() or a.is_also()) { @@ -134,12 +134,12 @@ inline namespace kernel return f; }); - define("set-batch!", [this](let const& xs) { return batch = car(xs); }); - define("set-debug!", [this](let const& xs) { return debug = car(xs); }); - define("set-interactive!", [this](let const& xs) { return interactive = car(xs); }); - define("set-prompt!", [this](let const& xs) { return prompt = car(xs); }); - define("set-trace!", [this](let const& xs) { return trace = car(xs); }); - define("set-verbose!", [this](let const& xs) { return verbose = car(xs); }); + define("set-batch!", [this](let const& xs, auto&&) { return batch = car(xs); }); + define("set-debug!", [this](let const& xs, auto&&) { return debug = car(xs); }); + define("set-interactive!", [this](let const& xs, auto&&) { return interactive = car(xs); }); + define("set-prompt!", [this](let const& xs, auto&&) { return prompt = car(xs); }); + define("set-trace!", [this](let const& xs, auto&&) { return trace = car(xs); }); + define("set-verbose!", [this](let const& xs, auto&&) { return verbose = car(xs); }); } auto environment::load(std::string const& s) -> object diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index c54e9b161..431731613 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -85,13 +85,11 @@ inline namespace kernel switch ((*iter).as().value) { - case mnemonic::call: case mnemonic::cons: case mnemonic::drop: case mnemonic::dummy: case mnemonic::join: case mnemonic::letrec: - case mnemonic::tail_call: os << *iter << "\n"; ++offset; break; @@ -102,6 +100,7 @@ inline namespace kernel ++offset; break; + case mnemonic::call: case mnemonic::define: case mnemonic::define_syntax: case mnemonic::fork: @@ -114,6 +113,7 @@ inline namespace kernel case mnemonic::store_absolute: case mnemonic::store_relative: case mnemonic::store_variadic: + case mnemonic::tail_call: os << *iter << " " << *++iter << "\n"; offset += 2; break; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 026abc32e..a5d82e62a 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -48,7 +48,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eqv?", [](let const& xs) // TODO Rename to value=? + define("eqv?", [](let const& xs, auto &&) // TODO Rename to value=? { return eqv(car(xs), cadr(xs)) ? t : f; }); @@ -72,7 +72,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eq?", [](auto&& xs) // TODO Rename to reference=? + define("eq?", [](auto&& xs, auto &&) // TODO Rename to reference=? { return eq(car(xs), cadr(xs)) ? t : f; }); @@ -99,11 +99,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number?", [](let const& xs) { return car(xs).is_also() ? t : f; }); - define("complex?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_complex () ? t : f; }); - define("real?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_real () ? t : f; }); - define("rational?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); - define("integer?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); + define("number?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); + define("complex?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_complex () ? t : f; }); + define("real?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_real () ? t : f; }); + define("rational?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); + define("integer?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); define("%complex?", is()); define("ratio?", is()); @@ -156,7 +156,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, COMPARE) \ - define(#SYMBOL, [](let const& xs) \ + define(#SYMBOL, [](let const& xs, auto &&) \ { \ return std::adjacent_find( \ std::begin(xs), std::end(xs), [](let const& a, let const& b) \ @@ -183,8 +183,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("+", [](let const& xs) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); - define("*", [](let const& xs) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); + define("+", [](let const& xs, auto&&) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); + define("*", [](let const& xs, auto&&) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); /* ------------------------------------------------------------------------- * @@ -205,7 +205,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, FUNCTION, BASIS) \ - define(SYMBOL, [](let const& xs) \ + define(SYMBOL, [](let const& xs, auto&&) \ { \ switch (length(xs)) \ { \ @@ -247,10 +247,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("floor", [](let const& xs) { return car(xs).as().floor(); }); - define("ceiling", [](let const& xs) { return car(xs).as().ceil(); }); - define("truncate", [](let const& xs) { return car(xs).as().trunc(); }); - define("round", [](let const& xs) { return car(xs).as().round(); }); + define("floor", [](let const& xs, auto&&) { return car(xs).as().floor(); }); + define("ceiling", [](let const& xs, auto&&) { return car(xs).as().ceil(); }); + define("truncate", [](let const& xs, auto&&) { return car(xs).as().trunc(); }); + define("round", [](let const& xs, auto&&) { return car(xs).as().round(); }); /* ------------------------------------------------------------------------- * @@ -265,7 +265,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("expt", [](let const& xs) + define("expt", [](let const& xs, auto&&) { return car(xs).as().pow(cadr(xs)); }); @@ -306,8 +306,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "exact", [](let const& xs) { return car(xs).as().exact (); }); - define("inexact", [](let const& xs) { return car(xs).as().inexact(); }); + define( "exact", [](let const& xs, auto&&) { return car(xs).as().exact (); }); + define("inexact", [](let const& xs, auto&&) { return car(xs).as().inexact(); }); /* ------------------------------------------------------------------------- * @@ -346,7 +346,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number->string", [](auto&& xs) + define("number->string", [](auto&& xs, auto&&) { return make(lexical_cast(car(xs))); }); @@ -368,7 +368,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->number", [](let const& xs) + define("string->number", [](let const& xs, auto&&) { switch (length(xs)) { @@ -404,7 +404,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("cons", construction, [](let const& xs) + define("cons", construction, [](let const& xs, auto&&) { return cons(car(xs), cadr(xs)); }); @@ -423,8 +423,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("car", [](let const& xs) { return caar(xs); }); - define("cdr", [](let const& xs) { return cdar(xs); }); + define("car", [](let const& xs, auto&&) { return caar(xs); }); + define("cdr", [](let const& xs, auto&&) { return cdar(xs); }); /* ------------------------------------------------------------------------- * @@ -438,8 +438,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("set-car!", [](auto&& xs) { return caar(xs) = cadr(xs); }); - define("set-cdr!", [](auto&& xs) { return cdar(xs) = cadr(xs); }); + define("set-car!", [](auto&& xs, auto&&) { return caar(xs) = cadr(xs); }); + define("set-cdr!", [](auto&& xs, auto&&) { return cdar(xs) = cadr(xs); }); /* ------------------------------------------------------------------------- * @@ -457,10 +457,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caar", [](let const& xs) { return caar(car(xs)); }); - define("cadr", [](let const& xs) { return cadr(car(xs)); }); - define("cdar", [](let const& xs) { return cdar(car(xs)); }); - define("cddr", [](let const& xs) { return cddr(car(xs)); }); + define("caar", [](let const& xs, auto&&) { return caar(car(xs)); }); + define("cadr", [](let const& xs, auto&&) { return cadr(car(xs)); }); + define("cdar", [](let const& xs, auto&&) { return cdar(car(xs)); }); + define("cddr", [](let const& xs, auto&&) { return cddr(car(xs)); }); /* ------------------------------------------------------------------------- * @@ -470,7 +470,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("null?", [](let const& xs) + define("null?", [](let const& xs, auto&&) { return car(xs).is() ? t : f; }); @@ -495,7 +495,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol->string", [](let const& xs) + define("symbol->string", [](let const& xs, auto&&) { return make(car(xs).as()); }); @@ -510,7 +510,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->symbol", [](let const& xs) + define("string->symbol", [](let const& xs, auto&&) { return intern(car(xs).as()); }); @@ -542,7 +542,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char->integer", [](let const& xs) + define("char->integer", [](let const& xs, auto&&) { if (xs.is() and car(xs).is()) { @@ -554,7 +554,7 @@ namespace meevax } }); - define("integer->char", [](let const& xs) + define("integer->char", [](let const& xs, auto&&) { if (xs.is() and car(xs).is()) { @@ -587,7 +587,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-string", [](let const& xs) + define("make-string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -610,7 +610,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-length", [](let const& xs) + define("string-length", [](let const& xs, auto&&) { return make(car(xs).as().size()); }); @@ -625,7 +625,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-ref", [](let const& xs) + define("string-ref", [](let const& xs, auto&&) { return make(car(xs).as().at(static_cast(cadr(xs).as()))); }); @@ -648,7 +648,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-set!", [](let const& xs) + define("string-set!", [](let const& xs, auto&&) { car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs).as(); return car(xs); @@ -690,7 +690,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define STRING_COMPARE(OPERATOR) \ - [](let const& xs) \ + [](let const& xs, auto&&) \ { \ for (let const& each : cdr(xs)) \ { \ @@ -724,7 +724,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-append", [](let const& xs) + define("string-append", [](let const& xs, auto&&) { string result; @@ -753,7 +753,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->list", [](let const& xs) + define("string->list", [](let const& xs, auto&&) { switch (length(xs)) { @@ -771,7 +771,7 @@ namespace meevax } }); - define("list->string", [](let const& xs) + define("list->string", [](let const& xs, auto&&) { string s; @@ -794,7 +794,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-copy", [](let const& xs) + define("string-copy", [](let const& xs, auto&&) { switch (length(xs)) { @@ -833,7 +833,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-vector", [](let const& xs) + define("make-vector", [](let const& xs, auto&&) { switch (length(xs)) { @@ -857,9 +857,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector", [](auto&&... xs) + define("vector", [](let const& xs, auto&&) { - return make(for_each_in, std::forward(xs)...); + return make(for_each_in, xs); }); /* ------------------------------------------------------------------------- @@ -870,7 +870,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-length", [](let const& xs) + define("vector-length", [](let const& xs, auto&&) { return make(car(xs).as().size()); }); @@ -884,7 +884,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-ref", [](let const& xs) + define("vector-ref", [](let const& xs, auto&&) { return car(xs).as().at(static_cast(cadr(xs).as())); }); @@ -898,7 +898,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-set!", [](let const& xs) + define("vector-set!", [](let const& xs, auto&&) { return car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs); }); @@ -918,7 +918,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->list", [](let const& xs) + define("vector->list", [](let const& xs, auto&&) { switch (length(xs)) { @@ -936,7 +936,7 @@ namespace meevax } }); - define("list->vector", [](let const& xs) + define("list->vector", [](let const& xs, auto&&) { return make(for_each_in, car(xs)); }); @@ -963,7 +963,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->string", [](let const& xs) + define("vector->string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1012,7 +1012,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-fill!", [](let const& xs) + define("vector-fill!", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1062,7 +1062,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("default-exception-handler", [](let const& xs) -> object + define("default-exception-handler", [](let const& xs, auto&&) -> object { throw car(xs); }); @@ -1083,7 +1083,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-error", [](let const& xs) + define("make-error", [](let const& xs, auto&&) { return make(car(xs), cdr(xs)); }); @@ -1118,11 +1118,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "input-port?", [](let const& xs) { return car(xs).is_also() ? t : f; }); - define( "output-port?", [](let const& xs) { return car(xs).is_also() ? t : f; }); - define( "binary-port?", [](let const& ) { return f; }); - define("textual-port?", [](let const& xs) { return car(xs).is_also() ? t : f; }); - define( "port?", [](let const& xs) { return car(xs).is_also() ? t : f; }); + define( "input-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); + define( "output-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); + define( "binary-port?", [](let const& , auto&&) { return f; }); + define("textual-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); + define( "port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); /* ------------------------------------------------------------------------- * @@ -1134,7 +1134,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("input-port-open?", [](let const& xs) + define("input-port-open?", [](let const& xs, auto&&) { if (let const& x = car(xs); x.is_also()) { @@ -1146,7 +1146,7 @@ namespace meevax } }); - define("output-port-open?", [](let const& xs) + define("output-port-open?", [](let const& xs, auto&&) { if (let const& x = car(xs); x.is_also()) { @@ -1171,9 +1171,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("standard-input-port", [](auto&&) { return standard_input; }); - define("standard-output-port", [](auto&&) { return standard_output; }); - define("standard-error-port", [](auto&&) { return standard_error; }); + define("standard-input-port", [](auto&&...) { return standard_input; }); + define("standard-output-port", [](auto&&...) { return standard_output; }); + define("standard-error-port", [](auto&&...) { return standard_error; }); /* ------------------------------------------------------------------------- * @@ -1187,7 +1187,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-file", [](let const& xs) + define("open-input-file", [](let const& xs, auto&&) { return make(car(xs).as()); }); @@ -1205,7 +1205,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-file", [](let const& xs) + define("open-output-file", [](let const& xs, auto&&) { return make(car(xs).as()); }); @@ -1227,7 +1227,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("close-input-port", [](let const& xs) + define("close-input-port", [](let const& xs, auto&&) { if (let const& x = car(xs); x.is_also()) { @@ -1237,7 +1237,7 @@ namespace meevax return unspecified_object; }); - define("close-output-port", [](let const& xs) + define("close-output-port", [](let const& xs, auto&&) { if (let const& x = car(xs); x.is_also()) { @@ -1257,7 +1257,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-string", [](let const& xs) + define("open-input-string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1281,7 +1281,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-string", [](let const& xs) + define("open-output-string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1308,7 +1308,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("get-output-string", [](let const& xs) + define("get-output-string", [](let const& xs, auto&&) { return make(car(xs).as().str()); }); @@ -1324,7 +1324,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-char", [](let const& xs) + define("%read-char", [](let const& xs, auto&&) { try { @@ -1359,7 +1359,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%peek-char", [](let const& xs) + define("%peek-char", [](let const& xs, auto&&) { try { @@ -1399,7 +1399,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eof-object", [](auto&&) + define("eof-object", [](auto&&...) { return eof_object; }); @@ -1424,7 +1424,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%char-ready?", [](let const& xs) + define("%char-ready?", [](let const& xs, auto&&) { return car(xs).as() ? t : f; }); @@ -1441,7 +1441,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-string", [](let const& xs) + define("%read-string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1464,7 +1464,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("put-char", [](let const& xs) + define("put-char", [](let const& xs, auto&&) { cadr(xs).as() << static_cast(car(xs).as()); return unspecified_object; @@ -1482,7 +1482,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("put-string", [](let const& xs) + define("put-string", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1510,7 +1510,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%flush-output-port", [](let const& xs) + define("%flush-output-port", [](let const& xs, auto&&) { car(xs).as() << std::flush; return unspecified_object; @@ -1549,7 +1549,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("digit-value", [](let const& xs) + define("digit-value", [](let const& xs, auto&&) { if (auto c = car(xs).as(); std::isdigit(c.codepoint)) { @@ -1604,31 +1604,31 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caaar", [](let const& xs) { return caaar(car(xs)); }); - define("caadr", [](let const& xs) { return caadr(car(xs)); }); - define("cadar", [](let const& xs) { return cadar(car(xs)); }); - define("caddr", [](let const& xs) { return caddr(car(xs)); }); - define("cdaar", [](let const& xs) { return cdaar(car(xs)); }); - define("cdadr", [](let const& xs) { return cdadr(car(xs)); }); - define("cddar", [](let const& xs) { return cddar(car(xs)); }); - define("cdddr", [](let const& xs) { return cdddr(car(xs)); }); - - define("caaaar", [](let const& xs) { return caaaar(car(xs)); }); - define("caaadr", [](let const& xs) { return caaadr(car(xs)); }); - define("caadar", [](let const& xs) { return caadar(car(xs)); }); - define("caaddr", [](let const& xs) { return caaddr(car(xs)); }); - define("cadaar", [](let const& xs) { return cadaar(car(xs)); }); - define("cadadr", [](let const& xs) { return cadadr(car(xs)); }); - define("caddar", [](let const& xs) { return caddar(car(xs)); }); - define("cadddr", [](let const& xs) { return cadddr(car(xs)); }); - define("cdaaar", [](let const& xs) { return cdaaar(car(xs)); }); - define("cdaadr", [](let const& xs) { return cdaadr(car(xs)); }); - define("cdadar", [](let const& xs) { return cdadar(car(xs)); }); - define("cdaddr", [](let const& xs) { return cdaddr(car(xs)); }); - define("cddaar", [](let const& xs) { return cddaar(car(xs)); }); - define("cddadr", [](let const& xs) { return cddadr(car(xs)); }); - define("cdddar", [](let const& xs) { return cdddar(car(xs)); }); - define("cddddr", [](let const& xs) { return cddddr(car(xs)); }); + define("caaar", [](let const& xs, auto&&) { return caaar(car(xs)); }); + define("caadr", [](let const& xs, auto&&) { return caadr(car(xs)); }); + define("cadar", [](let const& xs, auto&&) { return cadar(car(xs)); }); + define("caddr", [](let const& xs, auto&&) { return caddr(car(xs)); }); + define("cdaar", [](let const& xs, auto&&) { return cdaar(car(xs)); }); + define("cdadr", [](let const& xs, auto&&) { return cdadr(car(xs)); }); + define("cddar", [](let const& xs, auto&&) { return cddar(car(xs)); }); + define("cdddr", [](let const& xs, auto&&) { return cdddr(car(xs)); }); + + define("caaaar", [](let const& xs, auto&&) { return caaaar(car(xs)); }); + define("caaadr", [](let const& xs, auto&&) { return caaadr(car(xs)); }); + define("caadar", [](let const& xs, auto&&) { return caadar(car(xs)); }); + define("caaddr", [](let const& xs, auto&&) { return caaddr(car(xs)); }); + define("cadaar", [](let const& xs, auto&&) { return cadaar(car(xs)); }); + define("cadadr", [](let const& xs, auto&&) { return cadadr(car(xs)); }); + define("caddar", [](let const& xs, auto&&) { return caddar(car(xs)); }); + define("cadddr", [](let const& xs, auto&&) { return cadddr(car(xs)); }); + define("cdaaar", [](let const& xs, auto&&) { return cdaaar(car(xs)); }); + define("cdaadr", [](let const& xs, auto&&) { return cdaadr(car(xs)); }); + define("cdadar", [](let const& xs, auto&&) { return cdadar(car(xs)); }); + define("cdaddr", [](let const& xs, auto&&) { return cdaddr(car(xs)); }); + define("cddaar", [](let const& xs, auto&&) { return cddaar(car(xs)); }); + define("cddadr", [](let const& xs, auto&&) { return cddadr(car(xs)); }); + define("cdddar", [](let const& xs, auto&&) { return cdddar(car(xs)); }); + define("cddddr", [](let const& xs, auto&&) { return cddddr(car(xs)); }); } template <> @@ -1646,7 +1646,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eval", [](let const& xs) + define("eval", [](let const& xs, auto&&) { return cadr(xs).as().evaluate(car(xs)); }); @@ -1665,7 +1665,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("finite?", [](let const& xs) + define("finite?", [](let const& xs, auto&&) { return car(xs).as().is_finite() ? t : f; }); @@ -1680,7 +1680,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("infinite?", [](let const& xs) + define("infinite?", [](let const& xs, auto&&) { return car(xs).as().is_infinite() ? t : f; }); @@ -1695,15 +1695,15 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("nan?", [](let const& xs) + define("nan?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_nan() ? t : f; }); - define("exp", [](let const& xs) { return car(xs).as().exp(); }); - define("sqrt", [](let const& xs) { return car(xs).as().sqrt(); }); + define("exp", [](let const& xs, auto&&) { return car(xs).as().exp(); }); + define("sqrt", [](let const& xs, auto&&) { return car(xs).as().sqrt(); }); - define("log", [](let const& xs) + define("log", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1718,19 +1718,19 @@ namespace meevax } }); - define("sin", [](let const& xs) { return car(xs).as().sin(); }); - define("cos", [](let const& xs) { return car(xs).as().cos(); }); - define("tan", [](let const& xs) { return car(xs).as().tan(); }); - define("asin", [](let const& xs) { return car(xs).as().asin(); }); - define("acos", [](let const& xs) { return car(xs).as().acos(); }); - define("sinh", [](let const& xs) { return car(xs).as().sinh(); }); - define("cosh", [](let const& xs) { return car(xs).as().cosh(); }); - define("tanh", [](let const& xs) { return car(xs).as().tanh(); }); - define("asinh", [](let const& xs) { return car(xs).as().asinh(); }); - define("acosh", [](let const& xs) { return car(xs).as().acosh(); }); - define("atanh", [](let const& xs) { return car(xs).as().atanh(); }); + define("sin", [](let const& xs, auto&&) { return car(xs).as().sin(); }); + define("cos", [](let const& xs, auto&&) { return car(xs).as().cos(); }); + define("tan", [](let const& xs, auto&&) { return car(xs).as().tan(); }); + define("asin", [](let const& xs, auto&&) { return car(xs).as().asin(); }); + define("acos", [](let const& xs, auto&&) { return car(xs).as().acos(); }); + define("sinh", [](let const& xs, auto&&) { return car(xs).as().sinh(); }); + define("cosh", [](let const& xs, auto&&) { return car(xs).as().cosh(); }); + define("tanh", [](let const& xs, auto&&) { return car(xs).as().tanh(); }); + define("asinh", [](let const& xs, auto&&) { return car(xs).as().asinh(); }); + define("acosh", [](let const& xs, auto&&) { return car(xs).as().acosh(); }); + define("atanh", [](let const& xs, auto&&) { return car(xs).as().atanh(); }); - define("atan", [](let const& xs) + define("atan", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1772,7 +1772,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("load", [this](let const& xs) + define("load", [this](let const& xs, auto&&) { return load(car(xs).as()); }); @@ -1795,7 +1795,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("emergency-exit", [](let const& xs) -> object + define("emergency-exit", [](let const& xs, auto&&) -> object { switch (length(xs)) { @@ -1847,7 +1847,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read", [this](let const& xs) + define("%read", [this](let const& xs, auto&&) { try { @@ -1888,7 +1888,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%write-simple", [this](let const& xs) + define("%write-simple", [this](let const& xs, auto&&) { write(cadr(xs), car(xs)); return unspecified_object; @@ -1913,7 +1913,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier?", [](let const& xs) + define("identifier?", [](let const& xs, auto&&) { let const& x = car(xs); return x.is_also() or x.is() ? t : f; @@ -1952,7 +1952,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier->symbol", [](let const& xs) + define("identifier->symbol", [](let const& xs, auto&&) { switch (length(xs)) { @@ -1976,7 +1976,7 @@ namespace meevax define("r6rs:identifier?", is()); - define("macroexpand-1", [this](let const& xs) + define("macroexpand-1", [this](let const& xs, auto&&) { if (let const& macro = (*this)[caar(xs)]; macro.is()) { @@ -1988,7 +1988,7 @@ namespace meevax } }); - define("disassemble", [](let const& xs) + define("disassemble", [](let const& xs, auto&&) { if (0 < length(xs)) { @@ -2001,22 +2001,22 @@ namespace meevax return standard_output; }); - define("gc-collect", [](auto&&) + define("gc-collect", [](auto&&...) { return make(gc.collect()); }); - define("gc-count", [](auto&&) + define("gc-count", [](auto&&...) { return make(gc.count()); }); - define("ieee-float?", [](auto&&) + define("ieee-float?", [](auto&&...) { return std::numeric_limits::is_iec559 ? t : f; }); - define("print", [](let const& xs) + define("print", [](let const& xs, auto&&) { for (let const& x : xs) { @@ -2041,12 +2041,12 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("foreign-function", [](let const& xs) + define("foreign-function", [](let const& xs, auto&&) { return make(cadr(xs).as(), car(xs).as()); }); - define("type-of", [](auto&& xs) + define("type-of", [](let const& xs, auto&&) { std::cout << car(xs).type().name() << std::endl; diff --git a/test/vector.cpp b/test/vector.cpp index b7fa4f198..f0f589baa 100644 --- a/test/vector.cpp +++ b/test/vector.cpp @@ -173,9 +173,9 @@ auto main() -> int { auto module = environment(); - module.define("vector", [](auto&&... xs) + module.define("vector", [](let const& xs, auto&&) { - return make(for_each_in, std::forward(xs)...); + return make(for_each_in, xs); }); module.evaluate(module.read("(vector 1 2 3)")); From 45daef13bb86879a69a825b9b74c94e92edca04f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 02:16:48 +0900 Subject: [PATCH 021/118] Revert some changes for instruction `call` and `tail-call` --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 8 +++----- include/meevax/kernel/machine.hpp | 28 +++++++++++++--------------- src/kernel/instruction.cpp | 4 ++-- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 648eb12ae..89a36de43 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.842.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.843.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.842_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.843_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.842 +Meevax Lisp System, version 0.3.843 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 659514a65..a9406dc09 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.842 +0.3.843 diff --git a/basis/overture.ss b/basis/overture.ss index 898e1ba76..e795ffb0d 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -193,11 +193,6 @@ #f) (any-2+ f (cons x xs)))) -(define-syntax (letrec* bindings . body) - ((lambda (definitions) - `((,lambda () ,@definitions ,@body)) ) - (map (lambda (x) (cons define x)) bindings))) - (define-syntax (let bindings . body) (if (identifier? bindings) `(,letrec ((,bindings (,lambda ,(map car (car body)) ,@(cdr body)))) @@ -210,6 +205,9 @@ `(,let (,(car bindings)) ,@body) `(,let (,(car bindings)) (,let* ,(cdr bindings) ,@body)))) +(define-syntax (letrec* bindings . body) + `(,let () ,@(map (lambda (x) (cons define x)) bindings) ,@body)) + (define (member o x . c) ; for case (let ((compare (if (pair? c) (car c) equal?))) (let member ((x x)) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 9a2573b4e..9ed0d192c 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -127,7 +127,7 @@ inline namespace kernel assert(cdr(c).template is()); s = list(spec, cons(std::forward(xs)...)); - c = cons(make(mnemonic::call), environment::local(), c); + c = cons(make(mnemonic::call), c); return environment::execute(); } @@ -280,7 +280,7 @@ inline namespace kernel current_environment, car(expression), frames, - cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), frames, + cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_continuation))); } } @@ -514,28 +514,27 @@ inline namespace kernel case mnemonic::call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) + * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) * * where = (c' . e') * * ------------------------------------------------------------------- */ { - d = cons(cddr(s), e, cddr(c), d); + d = cons(cddr(s), e, cdr(c), d); c = callee.as().c(); e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), static_cast(*this)), - cddr(s)); - c = cddr(c); + s = cons(callee.as().apply(cadr(s), static_cast(*this)), cddr(s)); + c = cdr(c); } else if (callee.is()) /* --------------------------------- * @@ -559,7 +558,7 @@ inline namespace kernel case mnemonic::tail_call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d + * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d * * where = (c' . e') * @@ -571,19 +570,18 @@ inline namespace kernel } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%tail-call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), static_cast(*this)), - cddr(s)); - c = cddr(c); + s = cons(callee.as().apply(cadr(s), static_cast(*this)), cddr(s)); + c = cdr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%tail-call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -848,7 +846,7 @@ inline namespace kernel current_environment, car(expression), frames, - cons(make(mnemonic::call), frames, + cons(make(mnemonic::call), current_continuation))); } diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 431731613..c54e9b161 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -85,11 +85,13 @@ inline namespace kernel switch ((*iter).as().value) { + case mnemonic::call: case mnemonic::cons: case mnemonic::drop: case mnemonic::dummy: case mnemonic::join: case mnemonic::letrec: + case mnemonic::tail_call: os << *iter << "\n"; ++offset; break; @@ -100,7 +102,6 @@ inline namespace kernel ++offset; break; - case mnemonic::call: case mnemonic::define: case mnemonic::define_syntax: case mnemonic::fork: @@ -113,7 +114,6 @@ inline namespace kernel case mnemonic::store_absolute: case mnemonic::store_relative: case mnemonic::store_variadic: - case mnemonic::tail_call: os << *iter << " " << *++iter << "\n"; offset += 2; break; From 8f2cb037887fa9b2d431222433e8abdfb43f6cb6 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 03:25:26 +0900 Subject: [PATCH 022/118] Revert some changes for syntax `define-syntax` --- README.md | 6 +-- VERSION | 2 +- include/meevax/kernel/machine.hpp | 87 ++++++++++++++++--------------- 3 files changed, 48 insertions(+), 47 deletions(-) diff --git a/README.md b/README.md index 89a36de43..bc6438029 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.843.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.844.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.843_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.844_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.843 +Meevax Lisp System, version 0.3.844 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a9406dc09..b9864b20e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.843 +0.3.844 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 9ed0d192c..2f69e561f 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -407,6 +407,7 @@ inline namespace kernel d = cdr(d); goto decode; + case mnemonic::define_syntax: case mnemonic::define: /* ------------------------------------------------ * * (x' . s) e (%define . c) d => (x' . s) e c d @@ -414,31 +415,10 @@ inline namespace kernel * where = ( . x := x') * * ------------------------------------------------------------------- */ - cdadr(c) = car(s); + cadr(c).as().binding() = car(s); c = cddr(c); goto decode; - case mnemonic::define_syntax: /* ----------------------------------------- - * - * ( . s) e (%define-syntax ( . ) . c) d => ( . s) e c d - * - * where = ( . x := ) - * - * ------------------------------------------------------------------- */ - [&]() - { - // let const& frames = caadr(c); - - let const& identifier = cdadr(c); - - assert(car(s).template is()); - - identifier.as().binding() = car(s); - - c = cddr(c); - }(); - goto decode; - case mnemonic::let_syntax: /* -------------------------------------------- * * s e (%let_syntax . c) d => s e c' d @@ -1039,31 +1019,52 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (frames.is() or (current_context & context::outermost)) + // if (frames.is() or (current_context & context::outermost)) + // { + // if (car(expression).is()) // (define-syntax ( . ) ) + // { + // return compile(context::none, + // current_environment, + // list(make("fork/csc", fork_csc), + // cons(make("lambda", lambda), expression)), + // frames, + // cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(caar(expression))), + // current_continuation)); + // } + // else // (define-syntax x ...) + // { + // return compile(context::none, + // current_environment, + // cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), + // frames, + // cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(car(expression))), + // current_continuation)); + // } + // } + // else + // { + // throw syntax_error(make("definition cannot appear in this syntactic-context")); + // } + + if (car(expression).is()) // (define-syntax ( . xs) ) { - if (car(expression).is()) // (define-syntax ( . ) ) - { - return compile(context::none, - current_environment, - list(make("fork/csc", fork_csc), - cons(make("lambda", lambda), expression)), - frames, - cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(caar(expression))), - current_continuation)); - } - else // (define-syntax x ...) - { - return compile(context::none, - current_environment, - cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), - frames, - cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(car(expression))), - current_continuation)); - } + return define(current_context, + current_environment, + list(caar(expression), + list(make("fork/csc", fork_csc), + cons(make("lambda", lambda), expression) + ) + ), + frames, + current_continuation); } else { - throw syntax_error(make("definition cannot appear in this syntactic-context")); + return define(current_context, + current_environment, + expression, + frames, + current_continuation); } } From 952e16d89836137e793fc31b4f739b5e8210b6a1 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 04:23:20 +0900 Subject: [PATCH 023/118] Add new virtual member function `identifier::corresponding_mnemonic` --- README.md | 6 +-- VERSION | 2 +- basis/srfi-149.ss | 2 +- include/meevax/kernel/identifier.hpp | 9 +++++ include/meevax/kernel/machine.hpp | 55 ++++++++++++++++++---------- src/kernel/identifier.cpp | 15 ++++++++ src/library/meevax.cpp | 1 + 7 files changed, 65 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index bc6438029..fb2a2b51a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.844.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.845.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.844_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.845_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.844 +Meevax Lisp System, version 0.3.845 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b9864b20e..6b9a00955 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.844 +0.3.845 diff --git a/basis/srfi-149.ss b/basis/srfi-149.ss index 1ac5a42d7..c8f0b3c16 100644 --- a/basis/srfi-149.ss +++ b/basis/srfi-149.ss @@ -36,7 +36,7 @@ (define (cons-source kar kdr source) (cons kar kdr)) -(define syntax-quote quote) +(define syntax-quote quote-syntax) (define strip-syntactic-closures identity) diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 9bdbcf691..9f930ea1d 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -17,6 +17,7 @@ #ifndef INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP #define INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP +#include #include namespace meevax @@ -27,6 +28,8 @@ inline namespace kernel { using pair::pair; + virtual auto corresponding_mnemonic() const -> mnemonic = 0; + virtual auto is_bound() const -> bool = 0; virtual auto is_free() const -> bool = 0; @@ -40,6 +43,8 @@ inline namespace kernel { using identifier::identifier; + auto corresponding_mnemonic() const -> mnemonic override; + auto binding() -> reference; auto binding() const -> const_reference; @@ -58,6 +63,8 @@ inline namespace kernel { using identifier::identifier; + auto corresponding_mnemonic() const -> mnemonic override; + auto is_bound() const -> bool override; auto is_free() const -> bool override; @@ -66,6 +73,8 @@ inline namespace kernel struct variadic : public relative // de_bruijn_index { using relative::relative; + + auto corresponding_mnemonic() const -> mnemonic override; }; auto notate(const_reference, const_reference) -> object; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 2f69e561f..8f3e04ff7 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -191,17 +191,10 @@ inline namespace kernel { if (expression.is() or expression.is_also()) { - if (let const& identifier = current_environment.rename(expression, frames); identifier.is()) - { - return cons(make(mnemonic::load_absolute), identifier, - current_continuation); - } - else - { - return cons(identifier.is() ? make(mnemonic::load_relative) - : make(mnemonic::load_variadic), cdr(identifier), - current_continuation); - } + let const& renamed = current_environment.rename(expression, frames); + + return cons(make(renamed.as().corresponding_mnemonic()), renamed, + current_continuation); } else // is { @@ -301,26 +294,31 @@ inline namespace kernel { case mnemonic::load_relative: /* ----------------------------------------- * - * s e (%load-relative (i . j) . c) d => (x . s) e c d + * s e (%load-relative . c) d => (x . s) e c d * - * where x = (list-ref (list-ref E i) j) + * where = ( . (i . j)) * - * i = (caadr c) - * j = (cdadr c) + * x = (list-ref (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(list_ref(list_ref(e, caadr(c)), cdadr(c)), s); + s = cons(list_ref(list_ref(e, cadr(cadr(c).template as())), + cddr(cadr(c).template as())), + s); c = cddr(c); goto decode; case mnemonic::load_variadic: /* ----------------------------------------- * - * s e (%load-variadic (i . j) . c) d => (x . s) e c d + * s e (%load-variadic . c) d => (x . s) e c d + * + * where = ( . (i . j)) * - * where x = (list-tail (list-ref E i) j) + * x = (list-tail (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(list_tail(list_ref(e, caadr(c)), cdadr(c)), s); + s = cons(list_tail(list_ref(e, cadr(cadr(c).template as())), + cddr(cadr(c).template as())), + s); c = cddr(c); goto decode; @@ -415,7 +413,7 @@ inline namespace kernel * where = ( . x := x') * * ------------------------------------------------------------------- */ - cadr(c).as().binding() = car(s); + cadr(c).template as().binding() = car(s); c = cddr(c); goto decode; @@ -1250,6 +1248,23 @@ inline namespace kernel * set-car! or string-set!. * * ----------------------------------------------------------------------- */ + { + return cons(make(mnemonic::load_constant), car(expression), + current_continuation); + + // if (car(expression).is_also()) + // { + // return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), + // current_continuation); + // } + // else + // { + // return cons(make(mnemonic::load_constant), car(expression), + // current_continuation); + // } + } + + static SYNTAX(quote_syntax) { return cons(make(mnemonic::load_constant), car(expression), current_continuation); diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index af8e8aaff..b268513a6 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -33,6 +33,11 @@ inline namespace kernel return os << underline(datum.symbol()); } + auto absolute::corresponding_mnemonic() const -> mnemonic + { + return mnemonic::load_absolute; + } + auto absolute::binding() -> reference { return second; @@ -54,6 +59,11 @@ inline namespace kernel return binding().is() and binding().as() == *this; } + auto relative::corresponding_mnemonic() const -> mnemonic + { + return mnemonic::load_relative; + } + auto relative::is_bound() const -> bool { return not is_free(); @@ -64,6 +74,11 @@ inline namespace kernel return false; } + auto variadic::corresponding_mnemonic() const -> mnemonic + { + return mnemonic::load_variadic; + } + auto notate(const_reference variable, const_reference frames) -> object { for (auto outer = std::begin(frames); outer != std::end(frames); ++outer) diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index a5d82e62a..3cc62d7a5 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -34,6 +34,7 @@ namespace meevax define("letrec", letrec); define("letrec-syntax", letrec_syntax); define("quote", quote); + define("quote-syntax", quote_syntax); define("set!", set); /* ------------------------------------------------------------------------- From 16bd99a8c2d2e6ee2dd15c0625f0852c839c9804 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 04:39:39 +0900 Subject: [PATCH 024/118] Update syntax `quote` to strip identifier --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 23 ++++++++++------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index fb2a2b51a..cd7aacc20 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.845.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.846.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.845_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.846_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.845 +Meevax Lisp System, version 0.3.846 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6b9a00955..ab727436c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.845 +0.3.846 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 8f3e04ff7..63bd6ee27 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -1249,19 +1249,16 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - return cons(make(mnemonic::load_constant), car(expression), - current_continuation); - - // if (car(expression).is_also()) - // { - // return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), - // current_continuation); - // } - // else - // { - // return cons(make(mnemonic::load_constant), car(expression), - // current_continuation); - // } + if (car(expression).is_also()) + { + return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), + current_continuation); + } + else + { + return cons(make(mnemonic::load_constant), car(expression), + current_continuation); + } } static SYNTAX(quote_syntax) From 4b90fd1bd7939d9637f886cbace290a6479de77d Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 05:18:54 +0900 Subject: [PATCH 025/118] Add new virtual function `relative::strip` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 4 ++++ include/meevax/kernel/machine.hpp | 8 ++------ src/kernel/identifier.cpp | 10 ++++++++++ 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index cd7aacc20..4ccebc269 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.846.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.847.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.846_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.847_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.846 +Meevax Lisp System, version 0.3.847 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index ab727436c..de7965ecd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.846 +0.3.847 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 9f930ea1d..9de114348 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -68,6 +68,8 @@ inline namespace kernel auto is_bound() const -> bool override; auto is_free() const -> bool override; + + virtual auto strip(const_reference) const -> object; }; struct variadic : public relative // de_bruijn_index @@ -75,6 +77,8 @@ inline namespace kernel using relative::relative; auto corresponding_mnemonic() const -> mnemonic override; + + auto strip(const_reference) const -> object override; }; auto notate(const_reference, const_reference) -> object; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 63bd6ee27..8e32d3bbb 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -301,9 +301,7 @@ inline namespace kernel * x = (list-ref (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(list_ref(list_ref(e, cadr(cadr(c).template as())), - cddr(cadr(c).template as())), - s); + s = cons(cadr(c).template as().strip(e), s); c = cddr(c); goto decode; @@ -316,9 +314,7 @@ inline namespace kernel * x = (list-tail (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(list_tail(list_ref(e, cadr(cadr(c).template as())), - cddr(cadr(c).template as())), - s); + s = cons(cadr(c).template as().strip(e), s); c = cddr(c); goto decode; diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index b268513a6..dc3989033 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -74,11 +74,21 @@ inline namespace kernel return false; } + auto relative::strip(const_reference e) const -> object + { + return list_ref(list_ref(e, car(second)), cdr(second)); + } + auto variadic::corresponding_mnemonic() const -> mnemonic { return mnemonic::load_variadic; } + auto variadic::strip(const_reference e) const -> object + { + return list_tail(list_ref(e, car(second)), cdr(second)); + } + auto notate(const_reference variable, const_reference frames) -> object { for (auto outer = std::begin(frames); outer != std::end(frames); ++outer) From 3ea00a95ecc31dfc36f9ef2a8c5b07a24a70ac0f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 06:22:53 +0900 Subject: [PATCH 026/118] Remove member function `environment::rename(const_reference)` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 4 ---- include/meevax/kernel/list.hpp | 4 ++-- include/meevax/kernel/machine.hpp | 4 ++-- src/kernel/environment.cpp | 29 ++++++++------------------- 6 files changed, 16 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 4ccebc269..4ff91eaf1 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.847.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.848.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.847_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.848_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.847 +Meevax Lisp System, version 0.3.848 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index de7965ecd..fe92090ad 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.847 +0.3.848 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 4ebfed5f9..3dabd8208 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -92,12 +92,8 @@ inline namespace kernel auto local() noexcept -> reference; - auto rename(const_reference) -> const_reference; - auto rename(const_reference, const_reference) -> object; - auto rename(const_reference) const -> const_reference; - auto rename(const_reference, const_reference) const -> object; }; diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index f706b4c42..e14abfaea 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -44,12 +44,12 @@ inline namespace kernel } }; - auto car = [](auto&& x) noexcept -> decltype(auto) + auto car = [](auto&& x) -> decltype(auto) { return std::get<0>(unwrap(std::forward(x))); }; - auto cdr = [](auto&& x) noexcept -> decltype(auto) + auto cdr = [](auto&& x) -> decltype(auto) { return std::get<1>(unwrap(std::forward(x))); }; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 8e32d3bbb..659cf658c 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -940,7 +940,7 @@ inline namespace kernel current_environment, cons(make("lambda", lambda), cdar(expression), cdr(expression)), frames, - cons(make(mnemonic::define), current_environment.rename(caar(expression)), + cons(make(mnemonic::define), current_environment.rename(caar(expression), frames), current_continuation)); } else // (define x ...) @@ -949,7 +949,7 @@ inline namespace kernel current_environment, cdr(expression) ? cadr(expression) : unspecified_object, frames, - cons(make(mnemonic::define), current_environment.rename(car(expression)), + cons(make(mnemonic::define), current_environment.rename(car(expression), frames), current_continuation)); } } diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index c9621c167..fc777d9e7 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -22,7 +22,7 @@ inline namespace kernel { auto environment::operator [](const_reference name) -> const_reference { - return rename(name).as().binding(); + return rename(name, local()).as().binding(); } auto environment::operator [](std::string const& name) -> const_reference @@ -169,9 +169,13 @@ inline namespace kernel return first; } - auto environment::rename(const_reference variable) -> const_reference + auto environment::rename(const_reference variable, const_reference frames) -> object { - if (let const& binding = assq(variable, global()); select(binding)) + if (let const& identifier = notate(variable, frames); select(identifier)) + { + return identifier; + } + else if (let const& binding = assq(variable, global()); select(binding)) { return binding; } @@ -204,23 +208,6 @@ inline namespace kernel } } - auto environment::rename(const_reference variable, const_reference frames) -> object - { - if (let const& identifier = notate(variable, frames); select(identifier)) - { - return identifier; - } - else - { - return rename(variable); - } - } - - auto environment::rename(const_reference variable) const -> const_reference - { - return assq(variable, global()); - } - auto environment::rename(const_reference variable, const_reference frames) const -> object { if (let const& identifier = notate(variable, frames); select(identifier)) @@ -229,7 +216,7 @@ inline namespace kernel } else { - return rename(variable); // NOTE: In the const version, rename does not extend the global-environment. + return assq(variable, global()); } } From 2cca646a5100d6a6e15c359da40b96fabae845fd Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 11:14:33 +0900 Subject: [PATCH 027/118] Unify some duplicated codes of `environment::rename` Signed-off-by: yamacir-kit --- .github/workflows/build.yaml | 2 +- README.md | 6 +++--- VERSION | 2 +- src/kernel/environment.cpp | 24 ++++++++++-------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index cb66aa34c..89d1995e2 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,7 +6,7 @@ on: jobs: Ubuntu: runs-on: ${{ matrix.system }} - timeout-minutes: 180 + timeout-minutes: 240 env: CXX: ${{ matrix.compiler }} strategy: diff --git a/README.md b/README.md index 4ff91eaf1..a3f0b31fe 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.848.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.849.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.848_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.849_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.848 +Meevax Lisp System, version 0.3.849 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index fe92090ad..d06884498 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.848 +0.3.849 diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index fc777d9e7..03a4f6f7e 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -169,13 +169,21 @@ inline namespace kernel return first; } - auto environment::rename(const_reference variable, const_reference frames) -> object + auto environment::rename(const_reference variable, const_reference frames) const -> object { if (let const& identifier = notate(variable, frames); select(identifier)) { return identifier; } - else if (let const& binding = assq(variable, global()); select(binding)) + else + { + return assq(variable, global()); + } + } + + auto environment::rename(const_reference variable, const_reference frames) -> object + { + if (let const& binding = std::as_const(*this).rename(variable, frames); select(binding)) { return binding; } @@ -208,18 +216,6 @@ inline namespace kernel } } - auto environment::rename(const_reference variable, const_reference frames) const -> object - { - if (let const& identifier = notate(variable, frames); select(identifier)) - { - return identifier; - } - else - { - return assq(variable, global()); - } - } - auto operator >>(std::istream & is, environment & datum) -> std::istream & { datum.print("environment::operator >>(std::istream &, environment &)"); From a2c3c4d13e6d7dbb709601bf274d09dfbdb29631 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 12:43:44 +0900 Subject: [PATCH 028/118] Add new static member function `environment::is_renamable` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 2 ++ src/kernel/environment.cpp | 18 ++++++++++++++++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index a3f0b31fe..a5ea7ab43 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.849.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.850.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.849_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.850_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.849 +Meevax Lisp System, version 0.3.850 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index d06884498..9c180ca1d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.849 +0.3.850 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 3dabd8208..1a7d149be 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -86,6 +86,8 @@ inline namespace kernel auto import() -> void; + static auto is_renamable(const_reference) -> bool; + auto load(std::string const&) -> object; auto local() const noexcept -> const_reference; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 03a4f6f7e..626346054 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -142,6 +142,11 @@ inline namespace kernel define("set-verbose!", [this](let const& xs, auto&&) { return verbose = car(xs); }); } + auto environment::is_renamable(const_reference x) -> bool + { + return x.is() or x.is_also(); + } + auto environment::load(std::string const& s) -> object { if (let port = make(s); port and port.as().is_open()) @@ -171,7 +176,11 @@ inline namespace kernel auto environment::rename(const_reference variable, const_reference frames) const -> object { - if (let const& identifier = notate(variable, frames); select(identifier)) + if (not is_renamable(variable)) + { + return f; + } + else if (let const& identifier = notate(variable, frames); select(identifier)) { return identifier; } @@ -183,6 +192,10 @@ inline namespace kernel auto environment::rename(const_reference variable, const_reference frames) -> object { + if (not is_renamable(variable)) + { + return f; + } if (let const& binding = std::as_const(*this).rename(variable, frames); select(binding)) { return binding; @@ -205,10 +218,11 @@ inline namespace kernel * whereas it would be an error to perform a set! on an unbound variable. * * -------------------------------------------------------------------- */ + assert(is_renamable(variable)); let const id = make(variable); - cdr(id) = id; // NOTE: Identifier is self-evaluate if is unbound. + id.as().binding() = id; // NOTE: Identifier is self-evaluate if is unbound. global() = cons(id, global()); From ee83265e9f8759c9b0254ed60557b829d4e718f3 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 14:07:13 +0900 Subject: [PATCH 029/118] =?UTF-8?q?Update=20procedure=20`free-identifier?= =?UTF-8?q?=3D=3F`=20to=20use=20`environment::rename`?= Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- src/kernel/environment.cpp | 33 --------------------------------- src/library/meevax.cpp | 24 ++++++++++++++++++++++-- 4 files changed, 26 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index a5ea7ab43..18dcdec09 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.850.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.851.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.850_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.851_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.850 +Meevax Lisp System, version 0.3.851 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9c180ca1d..0a6fc9964 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.850 +0.3.851 diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 626346054..a165d8b33 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -101,39 +101,6 @@ inline namespace kernel auto environment::import() -> void { - define("free-identifier=?", [](let const& xs, auto&&) - { - if (let const& a = car(xs); a.is() or a.is_also()) - { - if (let const& b = cadr(xs); b.is() or b.is_also()) - { - if (let const& id1 = a.is_also() ? a.as().symbol() : a) - { - if (let const& id2 = b.is_also() ? b.as().symbol() : b) - { - return id1 == id2 ? t : f; - } - } - } - } - - // if (let const& a = car(xs); a.is() or a.is_also()) - // { - // if (let const& b = cadr(xs); b.is() or b.is_also()) - // { - // if (auto const& id1 = a.is_also() ? a.as() : locate(a).as(); id1.is_free()) - // { - // if (auto const& id2 = b.is_also() ? b.as() : locate(b).as(); id2.is_free()) - // { - // return id1 == id2 ? t : f; - // } - // } - // } - // } - - return f; - }); - define("set-batch!", [this](let const& xs, auto&&) { return batch = car(xs); }); define("set-debug!", [this](let const& xs, auto&&) { return debug = car(xs); }); define("set-interactive!", [this](let const& xs, auto&&) { return interactive = car(xs); }); diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 3cc62d7a5..0e48b947c 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1916,8 +1916,7 @@ namespace meevax define("identifier?", [](let const& xs, auto&&) { - let const& x = car(xs); - return x.is_also() or x.is() ? t : f; + return is_renamable(car(xs)) ? t : f; }); /* ------------------------------------------------------------------------- @@ -1942,6 +1941,27 @@ namespace meevax // TODO + /* ------------------------------------------------------------------------- + * + * (free-identifier=? id1 id2) procedure + * + * Returns #t if the original occurrences of id 1 and id 2 have the same + * binding, otherwise returns #f. free-identifier=? is used to look for a + * literal identifier in the argument to a transformer, such as else in a + * cond clause. A macro definition for syntax-rules would use + * free-identifier=? to look for literals in the input. + * + * ---------------------------------------------------------------------- */ + + define("free-identifier=?", [](let const& xs, environment & current) + { + let const& a = car(xs).is() ? current.rename( car(xs), current.local()) : car(xs); + let const& b = cadr(xs).is() ? current.rename(cadr(xs), current.local()) : cadr(xs); + + return a.is() and a.as().is_free() and + b.is() and b.as().is_free() and a == b ? t : f; + }); + /* ------------------------------------------------------------------------- * * (identifier->symbol id) procedure From b3ba55822f76492dda1aef52d4a5bf7943592000 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 14:37:00 +0900 Subject: [PATCH 030/118] Add new member function `environment::is_same_free_identifier` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 9 +++++++ src/library/meevax.cpp | 34 ++++++++++++++------------- 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 18dcdec09..e76caf98d 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.851.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.852.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.851_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.852_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.851 +Meevax Lisp System, version 0.3.852 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 0a6fc9964..9eb2a7a7d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.851 +0.3.852 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 1a7d149be..6ed04bbfb 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -77,6 +77,15 @@ inline namespace kernel auto execute(const_reference) -> object; + auto is_same_free_identifier(const_reference x, const_reference y) + { + let const& renamed_x = x.is() ? rename(x, local()) : x; + let const& renamed_y = y.is() ? rename(y, local()) : y; + + return renamed_x.is() and renamed_x.as().is_free() and + renamed_y.is() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); + } + auto global() noexcept -> reference; auto global() const noexcept -> const_reference; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 0e48b947c..54a63e9aa 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1953,13 +1953,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("free-identifier=?", [](let const& xs, environment & current) + define("free-identifier=?", [](let const& xs, environment & currently) { - let const& a = car(xs).is() ? current.rename( car(xs), current.local()) : car(xs); - let const& b = cadr(xs).is() ? current.rename(cadr(xs), current.local()) : cadr(xs); - - return a.is() and a.as().is_free() and - b.is() and b.as().is_free() and a == b ? t : f; + return currently.is_same_free_identifier(car(xs), cadr(xs)) ? t : f; }); /* ------------------------------------------------------------------------- @@ -2022,16 +2018,6 @@ namespace meevax return standard_output; }); - define("gc-collect", [](auto&&...) - { - return make(gc.collect()); - }); - - define("gc-count", [](auto&&...) - { - return make(gc.count()); - }); - define("ieee-float?", [](auto&&...) { return std::numeric_limits::is_iec559 ? t : f; @@ -2075,6 +2061,20 @@ namespace meevax }); } + template <> + auto environment::import(decltype("(meevax garbage-collector)"_s)) -> void + { + define("gc-collect", [](auto&&...) + { + return make(gc.collect()); + }); + + define("gc-count", [](auto&&...) + { + return make(gc.count()); + }); + } + template <> auto environment::import(decltype("(meevax srfis)"_s)) -> void { @@ -2115,7 +2115,9 @@ namespace meevax import("(meevax process-context)"_s); import("(meevax read)"_s); import("(meevax write)"_s); + import("(meevax experimental)"_s); + import("(meevax garbage-collector)"_s); import("(meevax srfis)"_s); } } // namespace meevax From 445d7d10ac4fc68642b53b23f5d8ec21cfb38175 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 15:35:53 +0900 Subject: [PATCH 031/118] Add new member function `environment::generate_free_identifier` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/environment.hpp | 28 +++++++++++++++-- src/kernel/environment.cpp | 43 +++++++++++---------------- src/kernel/identifier.cpp | 14 ++++----- src/library/meevax.cpp | 20 +++++++++++++ 6 files changed, 73 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index e76caf98d..cb748a666 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.852.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.853.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.852_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.853_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.852 +Meevax Lisp System, version 0.3.853 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9eb2a7a7d..6d707915e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.852 +0.3.853 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 6ed04bbfb..2733258be 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -77,13 +77,35 @@ inline namespace kernel auto execute(const_reference) -> object; - auto is_same_free_identifier(const_reference x, const_reference y) + auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool { let const& renamed_x = x.is() ? rename(x, local()) : x; let const& renamed_y = y.is() ? rename(y, local()) : y; - return renamed_x.is() and renamed_x.as().is_free() and - renamed_y.is() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); + return renamed_x.is_also() and renamed_x.as().is_bound() and + renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); + }; + + auto is_same_free_identifier(const_reference x, const_reference y) -> bool + { + let const& renamed_x = x.is() ? rename(x, local()) : x; + let const& renamed_y = y.is() ? rename(y, local()) : y; + + return renamed_x.is_also() and renamed_x.as().is_free() and + renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); + } + + auto generate_free_identifier(const_reference x) -> object + { + assert(is_renamable(x)); + + let const result = make(x); + + result.as().binding() = result; // NOTE: Identifier is self-evaluate if is free-identifier. + + assert(result.as().is_free()); + + return result; } auto global() noexcept -> reference; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index a165d8b33..c0c3e865a 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -167,33 +167,24 @@ inline namespace kernel { return binding; } - else + else /* -------------------------------------------------------------------- + * + * At the outermost level of a program, a definition + * + * (define ) + * + * has essentially the same effect as the assignment expression + * + * (set! ) + * + * if is bound to a non-syntax value. However, if is + * not bound, or is a syntactic keyword, then the definition will bind + * to a new location before performing the assignment, whereas + * it would be an error to perform a set! on an unbound variable. + * + * ----------------------------------------------------------------------- */ { - /* ----------------------------------------------------------------------- - * - * At the outermost level of a program, a definition - * - * (define ) - * - * has essentially the same effect as the assignment expression - * - * (set! ) - * - * if is bound to a non-syntax value. However, if - * is not bound, or is a syntactic keyword, then the definition will - * bind to a new location before performing the assignment, - * whereas it would be an error to perform a set! on an unbound variable. - * - * -------------------------------------------------------------------- */ - assert(is_renamable(variable)); - - let const id = make(variable); - - id.as().binding() = id; // NOTE: Identifier is self-evaluate if is unbound. - - global() = cons(id, global()); - - return car(global()); + return car(global() = cons(generate_free_identifier(variable), global())); } } diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index dc3989033..34a507515 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -55,8 +55,8 @@ inline namespace kernel auto absolute::is_free() const -> bool { - // NOTE: See environment::locate - return binding().is() and binding().as() == *this; + // NOTE: See environment::generate_free_identifier + return binding().is() and std::addressof(binding().as()) == this; } auto relative::corresponding_mnemonic() const -> mnemonic @@ -95,7 +95,11 @@ inline namespace kernel { for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) { - if (inner.is() and eq(*inner, variable)) + if (inner.is() and (*inner).is() and eq((*inner).as().symbol(), variable)) + { + return *inner; + } + else if (inner.is() and eq(*inner, variable)) { return make(variable, cons(make(std::distance(std::begin(frames), outer)), @@ -107,10 +111,6 @@ inline namespace kernel cons(make(std::distance(std::begin(frames), outer)), make(std::distance(std::begin(*outer), inner)))); } - else if (inner.is() and (*inner).is() and eq((*inner).as().symbol(), variable)) - { - return *inner; - } } } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 54a63e9aa..be212154b 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1958,6 +1958,26 @@ namespace meevax return currently.is_same_free_identifier(car(xs), cadr(xs)) ? t : f; }); + /* ------------------------------------------------------------------------- + * + * (bound-identifier=? id1 id2) procedure + * + * Returns #t if a binding for one of the two identifiers id 1 and id 2 + * would shadow free references to the other, otherwise returns #f. Two + * identifiers can be free-identifier=? without being bound-identifier=? + * if they were introduced at different stages in the expansion process. + * Bound-identifier=? can be used, for example, to detect duplicate + * identifiers in bound-variable lists. A macro definition of syntax-rules + * would use bound-identifier=? to look for pattern variables from the + * input pattern in the output template. + * + * ---------------------------------------------------------------------- */ + + define("bound-identifier=?", [](let const& xs, environment & currently) + { + return currently.is_same_bound_identifier(car(xs), cadr(xs)) ? t : f; + }); + /* ------------------------------------------------------------------------- * * (identifier->symbol id) procedure From bd60812446eb0115d0905d14c18f61e6276c8bb7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Feb 2022 15:49:20 +0900 Subject: [PATCH 032/118] Add new R4RS procedure `generate-identifier` --- README.md | 6 +++--- VERSION | 2 +- src/library/meevax.cpp | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cb748a666..763f318b4 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.853.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.854.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.853_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.854_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.853 +Meevax Lisp System, version 0.3.854 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6d707915e..5dd8eba4d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.853 +0.3.854 diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index be212154b..23e8b81da 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2009,6 +2009,43 @@ namespace meevax } }); + /* ------------------------------------------------------------------------- + * + * (generate-identifier) procedure + * (generate-identifier symbol) procedure + * + * Returns a new identifier. The optional argument to generate-identifier + * specifies the symbolic name of the resulting identifier. If no argument + * is supplied the name is unspecified. + * + * Generate-identifier is used to introduce bound identifiers into the + * output of a transformer. Since introduced bound identifiers are + * automatically renamed, generate-identifier is necessary only for + * distinguishing introduced identifiers when an indefinite number of them + * must be generated by a macro. + * + * The optional argument to generate-identifier specifies the symbolic + * name of the resulting identifier. If no argument is supplied the name + * is unspecified. The procedure identifier->symbol reveals the symbolic + * name of an identifier. + * + * ---------------------------------------------------------------------- */ + + define("generate-identifier", [](let const& xs, environment & current) + { + switch (length(xs)) + { + case 0: + return current.generate_free_identifier(make()); + + case 1: + return current.generate_free_identifier(car(xs)); + + default: + throw invalid_application(intern("generate-identifier") | xs); + } + }); + define("transformer?", is()); define("r6rs:identifier?", is()); From 7203ad5bde5b328e6b68469470667e3194f9706d Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Mar 2022 21:36:18 +0900 Subject: [PATCH 033/118] Update `absolute`, `relative` and `variadic` to inherit new type `notation` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 28 ++++++++++++++++++++-------- include/meevax/kernel/machine.hpp | 18 +++++++++--------- src/kernel/identifier.cpp | 10 ---------- 5 files changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 763f318b4..a7e8431f6 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.854.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.855.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.854_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.855_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.854 +Meevax Lisp System, version 0.3.855 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 5dd8eba4d..97b6c74e3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.854 +0.3.855 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 9de114348..1301e26d2 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -28,8 +28,6 @@ inline namespace kernel { using pair::pair; - virtual auto corresponding_mnemonic() const -> mnemonic = 0; - virtual auto is_bound() const -> bool = 0; virtual auto is_free() const -> bool = 0; @@ -39,7 +37,25 @@ inline namespace kernel auto operator <<(std::ostream &, identifier const&) -> std::ostream &; + struct notation : public virtual pair + { + using pair::pair; + + virtual auto corresponding_mnemonic() const -> mnemonic = 0; + + auto i() const -> const_reference + { + return first; + } + + auto j() const -> const_reference + { + return second; + } + }; + struct absolute : public identifier + , public notation { using identifier::identifier; @@ -59,16 +75,12 @@ inline namespace kernel using absolute::absolute; }; - struct relative : public identifier // de_bruijn_index + struct relative : public notation // de_bruijn_index { - using identifier::identifier; + using notation::notation; auto corresponding_mnemonic() const -> mnemonic override; - auto is_bound() const -> bool override; - - auto is_free() const -> bool override; - virtual auto strip(const_reference) const -> object; }; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 659cf658c..11a98d05d 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -193,7 +193,7 @@ inline namespace kernel { let const& renamed = current_environment.rename(expression, frames); - return cons(make(renamed.as().corresponding_mnemonic()), renamed, + return cons(make(renamed.as().corresponding_mnemonic()), renamed, current_continuation); } else // is @@ -1245,16 +1245,16 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (car(expression).is_also()) - { - return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), - current_continuation); - } - else - { + // if (car(expression).is_also()) + // { + // return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), + // current_continuation); + // } + // else + // { return cons(make(mnemonic::load_constant), car(expression), current_continuation); - } + // } } static SYNTAX(quote_syntax) diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 34a507515..9086d2deb 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -64,16 +64,6 @@ inline namespace kernel return mnemonic::load_relative; } - auto relative::is_bound() const -> bool - { - return not is_free(); - } - - auto relative::is_free() const -> bool - { - return false; - } - auto relative::strip(const_reference e) const -> object { return list_ref(list_ref(e, car(second)), cdr(second)); From 757845bdcc9bac04c939c645f1d9589e3312a349 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Mar 2022 22:10:56 +0900 Subject: [PATCH 034/118] Move struct `notation` to new header `notation.hpp` Signed-off-by: yamacir-kit --- README.md | 6 +-- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 38 +------------- include/meevax/kernel/notation.hpp | 77 ++++++++++++++++++++++++++++ src/kernel/identifier.cpp | 21 -------- 5 files changed, 82 insertions(+), 62 deletions(-) create mode 100644 include/meevax/kernel/notation.hpp diff --git a/README.md b/README.md index a7e8431f6..ce3215346 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.855.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.856.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.855_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.856_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.855 +Meevax Lisp System, version 0.3.856 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 97b6c74e3..a64450897 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.855 +0.3.856 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 1301e26d2..22047169c 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -17,8 +17,7 @@ #ifndef INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP #define INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP -#include -#include +#include namespace meevax { @@ -37,23 +36,6 @@ inline namespace kernel auto operator <<(std::ostream &, identifier const&) -> std::ostream &; - struct notation : public virtual pair - { - using pair::pair; - - virtual auto corresponding_mnemonic() const -> mnemonic = 0; - - auto i() const -> const_reference - { - return first; - } - - auto j() const -> const_reference - { - return second; - } - }; - struct absolute : public identifier , public notation { @@ -75,24 +57,6 @@ inline namespace kernel using absolute::absolute; }; - struct relative : public notation // de_bruijn_index - { - using notation::notation; - - auto corresponding_mnemonic() const -> mnemonic override; - - virtual auto strip(const_reference) const -> object; - }; - - struct variadic : public relative // de_bruijn_index - { - using relative::relative; - - auto corresponding_mnemonic() const -> mnemonic override; - - auto strip(const_reference) const -> object override; - }; - auto notate(const_reference, const_reference) -> object; } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp new file mode 100644 index 000000000..4d13102a6 --- /dev/null +++ b/include/meevax/kernel/notation.hpp @@ -0,0 +1,77 @@ +/* + Copyright 2018-2022 Tatsuya Yamasaki. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef INCLUDED_MEEVAX_KERNEL_NOTATION_HPP +#define INCLUDED_MEEVAX_KERNEL_NOTATION_HPP + +#include +#include +#include + +namespace meevax +{ +inline namespace kernel +{ + struct notation : public virtual pair + { + using pair::pair; + + virtual auto corresponding_mnemonic() const -> mnemonic = 0; + }; + + struct relative : public notation // de_bruijn_index + { + using notation::notation; + + auto corresponding_mnemonic() const -> mnemonic override + { + return mnemonic::load_relative; + } + + auto m() const -> const_reference + { + return car(second); + } + + auto n() const -> const_reference + { + return cdr(second); + } + + virtual auto strip(const_reference e) const -> object + { + return list_ref(list_ref(e, m()), n()); + } + }; + + struct variadic : public relative // de_bruijn_index + { + using relative::relative; + + auto corresponding_mnemonic() const -> mnemonic override + { + return mnemonic::load_variadic; + } + + auto strip(const_reference e) const -> object override + { + return list_tail(list_ref(e, m()), n()); + } + }; +} // namespace kernel +} // namespace meevax + +#endif // INCLUDED_MEEVAX_KERNEL_NOTATION_HPP diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 9086d2deb..5f170675d 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -16,7 +16,6 @@ #include #include -#include #include namespace meevax @@ -59,26 +58,6 @@ inline namespace kernel return binding().is() and std::addressof(binding().as()) == this; } - auto relative::corresponding_mnemonic() const -> mnemonic - { - return mnemonic::load_relative; - } - - auto relative::strip(const_reference e) const -> object - { - return list_ref(list_ref(e, car(second)), cdr(second)); - } - - auto variadic::corresponding_mnemonic() const -> mnemonic - { - return mnemonic::load_variadic; - } - - auto variadic::strip(const_reference e) const -> object - { - return list_tail(list_ref(e, car(second)), cdr(second)); - } - auto notate(const_reference variable, const_reference frames) -> object { for (auto outer = std::begin(frames); outer != std::end(frames); ++outer) From a8e843844ed3224c817318e690b93c3cea4d2d4a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Mar 2022 22:17:29 +0900 Subject: [PATCH 035/118] Rename member function `notation::corresponding_mnemonic` to `mnemonic` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 2 +- include/meevax/kernel/machine.hpp | 4 ++-- include/meevax/kernel/notation.hpp | 6 +++--- src/kernel/identifier.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index ce3215346..ee3641255 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.856.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.857.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.856_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.857_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.856 +Meevax Lisp System, version 0.3.857 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a64450897..8517ccad6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.856 +0.3.857 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 22047169c..55cf21d52 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -41,7 +41,7 @@ inline namespace kernel { using identifier::identifier; - auto corresponding_mnemonic() const -> mnemonic override; + auto mnemonic() const -> meevax::mnemonic override; auto binding() -> reference; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 11a98d05d..f70beecec 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -193,7 +193,7 @@ inline namespace kernel { let const& renamed = current_environment.rename(expression, frames); - return cons(make(renamed.as().corresponding_mnemonic()), renamed, + return cons(make(renamed.as().mnemonic()), renamed, current_continuation); } else // is @@ -1247,7 +1247,7 @@ inline namespace kernel { // if (car(expression).is_also()) // { - // return cons(make(car(expression).as().corresponding_mnemonic()), car(expression), + // return cons(make(car(expression).as().mnemonic()), car(expression), // current_continuation); // } // else diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 4d13102a6..0941abb46 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -29,14 +29,14 @@ inline namespace kernel { using pair::pair; - virtual auto corresponding_mnemonic() const -> mnemonic = 0; + virtual auto mnemonic() const -> mnemonic = 0; }; struct relative : public notation // de_bruijn_index { using notation::notation; - auto corresponding_mnemonic() const -> mnemonic override + auto mnemonic() const -> meevax::mnemonic override { return mnemonic::load_relative; } @@ -61,7 +61,7 @@ inline namespace kernel { using relative::relative; - auto corresponding_mnemonic() const -> mnemonic override + auto mnemonic() const -> meevax::mnemonic override { return mnemonic::load_variadic; } diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 5f170675d..28fe91310 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -32,7 +32,7 @@ inline namespace kernel return os << underline(datum.symbol()); } - auto absolute::corresponding_mnemonic() const -> mnemonic + auto absolute::mnemonic() const -> meevax::mnemonic { return mnemonic::load_absolute; } From 757ddf5c1bc3e96daefcc59135d40433eb880468 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 13 Mar 2022 22:43:52 +0900 Subject: [PATCH 036/118] Add new virtual member function `notation::load` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 5 ++++ include/meevax/kernel/machine.hpp | 34 ++++++++++++---------------- include/meevax/kernel/notation.hpp | 20 ++++++++-------- 5 files changed, 35 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index ee3641255..89b6c76fc 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.857.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.858.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.857_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.858_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.857 +Meevax Lisp System, version 0.3.858 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 8517ccad6..130f80ea9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.857 +0.3.858 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 55cf21d52..6ae9615ff 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -41,6 +41,11 @@ inline namespace kernel { using identifier::identifier; + auto load(const_reference) const -> object override + { + return second; + } + auto mnemonic() const -> meevax::mnemonic override; auto binding() -> reference; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index f70beecec..3379fed6c 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -292,29 +292,36 @@ inline namespace kernel switch (car(c).template as().value) { + case mnemonic::load_absolute: /* ----------------------------------------- + * + * s e (%load-absolute . c) d => (x . s) e c d + * + * where = ( . ) + * + * ------------------------------------------------------------------- */ + [[fallthrough]]; + case mnemonic::load_relative: /* ----------------------------------------- * - * s e (%load-relative . c) d => (x . s) e c d + * s e (%load-relative . c) d => (x . s) e c d * - * where = ( . (i . j)) + * where = ( i . j) * * x = (list-ref (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(cadr(c).template as().strip(e), s); - c = cddr(c); - goto decode; + [[fallthrough]]; case mnemonic::load_variadic: /* ----------------------------------------- * - * s e (%load-variadic . c) d => (x . s) e c d + * s e (%load-variadic . c) d => (x . s) e c d * - * where = ( . (i . j)) + * where = ( i . j) * * x = (list-tail (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(cadr(c).template as().strip(e), s); + s = cons(cadr(c).template as().load(e), s); c = cddr(c); goto decode; @@ -327,17 +334,6 @@ inline namespace kernel c = cddr(c); goto decode; - case mnemonic::load_absolute: /* ----------------------------------------- - * - * s e (%load-absolute . c) d => (x . s) e c d - * - * where = ( . x) - * - * ------------------------------------------------------------------- */ - s = cons(cdadr(c), s); - c = cddr(c); - goto decode; - case mnemonic::load_closure: /* ------------------------------------------ * * s e (%load-closure c' . c) d => ( . s) e c d diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 0941abb46..3eec62576 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -29,6 +29,8 @@ inline namespace kernel { using pair::pair; + virtual auto load(const_reference) const -> object = 0; + virtual auto mnemonic() const -> mnemonic = 0; }; @@ -36,6 +38,11 @@ inline namespace kernel { using notation::notation; + auto load(const_reference e) const -> object override + { + return list_ref(list_ref(e, m()), n()); + } + auto mnemonic() const -> meevax::mnemonic override { return mnemonic::load_relative; @@ -50,25 +57,20 @@ inline namespace kernel { return cdr(second); } - - virtual auto strip(const_reference e) const -> object - { - return list_ref(list_ref(e, m()), n()); - } }; struct variadic : public relative // de_bruijn_index { using relative::relative; - auto mnemonic() const -> meevax::mnemonic override + auto load(const_reference e) const -> object override { - return mnemonic::load_variadic; + return list_tail(list_ref(e, m()), n()); } - auto strip(const_reference e) const -> object override + auto mnemonic() const -> meevax::mnemonic override { - return list_tail(list_ref(e, m()), n()); + return mnemonic::load_variadic; } }; } // namespace kernel From 7f2f0bbb482bbb098c159f9e523ed800300e838e Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 14 Mar 2022 00:26:56 +0900 Subject: [PATCH 037/118] Rename member function `environment::rename` to `notate` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/environment.hpp | 14 +++++++-- include/meevax/kernel/machine.hpp | 42 +++++++++++++-------------- src/kernel/environment.cpp | 10 +++---- 5 files changed, 42 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 89b6c76fc..d457096cd 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.858.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.859.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.858_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.859_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.858 +Meevax Lisp System, version 0.3.859 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 130f80ea9..fdbd6b257 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.858 +0.3.859 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 2733258be..80af77435 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -125,9 +125,19 @@ inline namespace kernel auto local() noexcept -> reference; - auto rename(const_reference, const_reference) -> object; + auto notate(const_reference, const_reference) -> object; - auto rename(const_reference, const_reference) const -> object; + auto notate(const_reference, const_reference) const -> object; + + auto rename(const_reference symbol, const_reference syntactic_environment) -> object + { + return notate(symbol, syntactic_environment); + } + + auto rename(const_reference symbol, const_reference syntactic_environment) const -> object + { + return notate(symbol, syntactic_environment); + } }; auto operator >>(std::istream &, environment &) -> std::istream &; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 3379fed6c..8d50e7adc 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -189,11 +189,11 @@ inline namespace kernel * * --------------------------------------------------------------------- */ { - if (expression.is() or expression.is_also()) + if (expression.is() or expression.is_also()) { - let const& renamed = current_environment.rename(expression, frames); + let const& n = current_environment.notate(expression, frames); - return cons(make(renamed.as().mnemonic()), renamed, + return cons(make(n.as().mnemonic()), n, current_continuation); } else // is @@ -202,17 +202,17 @@ inline namespace kernel current_continuation); } } - else if (let const& identifier = std::as_const(current_environment).rename(car(expression), frames); identifier.is()) + else if (let const& notation = std::as_const(current_environment).notate(car(expression), frames); notation.is()) { - assert(identifier.as().binding().is()); + assert(notation.as().binding().is()); return compile(context::none, current_environment, - identifier.as().binding().as().macroexpand(identifier.as().binding(), cdr(expression)), + notation.as().binding().as().macroexpand(notation.as().binding(), cdr(expression)), frames, current_continuation); } - else if (let const& applicant = identifier.is() ? identifier.as().binding() : car(expression); applicant.is_also()) + else if (let const& applicant = notation.is() ? notation.as().binding() : car(expression); applicant.is_also()) { return applicant.as().transform(current_context, current_environment, @@ -400,9 +400,9 @@ inline namespace kernel case mnemonic::define_syntax: case mnemonic::define: /* ------------------------------------------------ * - * (x' . s) e (%define . c) d => (x' . s) e c d + * (x' . s) e (%define . c) d => (x' . s) e c d * - * where = ( . x := x') + * where = ( . x := x') * * ------------------------------------------------------------------- */ cadr(c).template as().binding() = car(s); @@ -621,9 +621,9 @@ inline namespace kernel case mnemonic::store_absolute: /* ---------------------------------------- * - * (x . s) e (%store-absolute . c) d => (x' . s) e c d + * (x . s) e (%store-absolute . c) d => (x' . s) e c d * - * where = ( . x') + * where = ( . x') * * ------------------------------------------------------------------- */ if (let const& binding = cadr(c); cdr(binding).is()) @@ -690,13 +690,13 @@ inline namespace kernel { throw syntax_error(make("set!"), expression); } - else if (let const& identifier = current_environment.rename(car(expression), frames); identifier.is()) + else if (let const& notation = current_environment.notate(car(expression), frames); notation.is()) { return compile(context::none, current_environment, cadr(expression), frames, - cons(make(mnemonic::store_absolute), identifier, + cons(make(mnemonic::store_absolute), notation, current_continuation)); } else @@ -705,8 +705,8 @@ inline namespace kernel current_environment, cadr(expression), frames, - cons(identifier.is() ? make(mnemonic::store_relative) - : make(mnemonic::store_variadic), cdr(identifier), // De Bruijn index + cons(notation.is() ? make(mnemonic::store_relative) + : make(mnemonic::store_variadic), cdr(notation), // De Bruijn index current_continuation)); } } @@ -717,9 +717,9 @@ inline namespace kernel { if (form.is()) { - if (let const& identifier = std::as_const(current_environment).rename(car(form), frames); identifier.is()) + if (let const& notation = std::as_const(current_environment).notate(car(form), frames); notation.is()) { - if (let const& callee = cdr(identifier); callee.is()) + if (let const& callee = notation.as().binding(); callee.is()) { return callee.as().name == "define"; } @@ -936,7 +936,7 @@ inline namespace kernel current_environment, cons(make("lambda", lambda), cdar(expression), cdr(expression)), frames, - cons(make(mnemonic::define), current_environment.rename(caar(expression), frames), + cons(make(mnemonic::define), current_environment.notate(caar(expression), frames), current_continuation)); } else // (define x ...) @@ -945,7 +945,7 @@ inline namespace kernel current_environment, cdr(expression) ? cadr(expression) : unspecified_object, frames, - cons(make(mnemonic::define), current_environment.rename(car(expression), frames), + cons(make(mnemonic::define), current_environment.notate(car(expression), frames), current_continuation)); } } @@ -1018,7 +1018,7 @@ inline namespace kernel // list(make("fork/csc", fork_csc), // cons(make("lambda", lambda), expression)), // frames, - // cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(caar(expression))), + // cons(make(mnemonic::define_syntax), cons(frames, current_environment.notate(caar(expression))), // current_continuation)); // } // else // (define-syntax x ...) @@ -1027,7 +1027,7 @@ inline namespace kernel // current_environment, // cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), // frames, - // cons(make(mnemonic::define_syntax), cons(frames, current_environment.rename(car(expression))), + // cons(make(mnemonic::define_syntax), cons(frames, current_environment.notate(car(expression))), // current_continuation)); // } // } diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index c0c3e865a..6d221b748 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -22,7 +22,7 @@ inline namespace kernel { auto environment::operator [](const_reference name) -> const_reference { - return rename(name, local()).as().binding(); + return notate(name, local()).as().binding(); } auto environment::operator [](std::string const& name) -> const_reference @@ -141,13 +141,13 @@ inline namespace kernel return first; } - auto environment::rename(const_reference variable, const_reference frames) const -> object + auto environment::notate(const_reference variable, const_reference frames) const -> object { if (not is_renamable(variable)) { return f; } - else if (let const& identifier = notate(variable, frames); select(identifier)) + else if (let const& identifier = meevax::notate(variable, frames); select(identifier)) { return identifier; } @@ -157,13 +157,13 @@ inline namespace kernel } } - auto environment::rename(const_reference variable, const_reference frames) -> object + auto environment::notate(const_reference variable, const_reference frames) -> object { if (not is_renamable(variable)) { return f; } - if (let const& binding = std::as_const(*this).rename(variable, frames); select(binding)) + if (let const& binding = std::as_const(*this).notate(variable, frames); select(binding)) { return binding; } From dd1a56752c79149c72e1208c7badcc88adcc43a7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 14 Mar 2022 18:55:39 +0900 Subject: [PATCH 038/118] Add new experimental type `syntactic_closure` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 32 ++++++++++++++++++++++++++-- include/meevax/kernel/machine.hpp | 2 +- src/kernel/environment.cpp | 2 +- src/kernel/identifier.cpp | 5 ----- src/library/meevax.cpp | 4 ++-- 7 files changed, 38 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d457096cd..8e1c3263f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.859.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.860.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.859_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.860_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.859 +Meevax Lisp System, version 0.3.860 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index fdbd6b257..6d8be1f8e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.859 +0.3.860 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 6ae9615ff..f6b358645 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -23,7 +23,7 @@ namespace meevax { inline namespace kernel { - struct identifier : public virtual pair + struct [[deprecated]] identifier : public virtual pair { using pair::pair; @@ -46,7 +46,10 @@ inline namespace kernel return second; } - auto mnemonic() const -> meevax::mnemonic override; + auto mnemonic() const -> meevax::mnemonic override + { + return mnemonic::load_absolute; + } auto binding() -> reference; @@ -62,6 +65,31 @@ inline namespace kernel using absolute::absolute; }; + struct syntactic_closure : public virtual pair // ( . e) + { + using pair::pair; + + auto symbol() const -> const_reference + { + return car(first); + } + + auto strip() + { + return first.as().load(second); + } + + auto is_bound() const -> bool + { + return not is_free(); + } + + auto is_free() const -> bool + { + return first.is() and first.as().is_free(); + } + }; + auto notate(const_reference, const_reference) -> object; } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 8d50e7adc..f8a3b0fc8 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -189,7 +189,7 @@ inline namespace kernel * * --------------------------------------------------------------------- */ { - if (expression.is() or expression.is_also()) + if (expression.is() or expression.is_also()) { let const& n = current_environment.notate(expression, frames); diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 6d221b748..889c69115 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -111,7 +111,7 @@ inline namespace kernel auto environment::is_renamable(const_reference x) -> bool { - return x.is() or x.is_also(); + return x.is() or x.is_also() or x.is(); } auto environment::load(std::string const& s) -> object diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 28fe91310..c928560c9 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -32,11 +32,6 @@ inline namespace kernel return os << underline(datum.symbol()); } - auto absolute::mnemonic() const -> meevax::mnemonic - { - return mnemonic::load_absolute; - } - auto absolute::binding() -> reference { return second; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 23e8b81da..c664dd9ed 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1994,9 +1994,9 @@ namespace meevax switch (length(xs)) { case 1: - if (let const& x = car(xs); x.is_also()) + if (let const& x = car(xs); x.is_also()) { - return x.as().symbol(); + return x.as().symbol(); } else if (x.is()) { From 5a9713f3fed31d8a6b7c5938ac0d3f79bd6e7ac7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 16 Mar 2022 19:58:14 +0900 Subject: [PATCH 039/118] Remove struct `identifier` --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 8 ++++---- include/meevax/kernel/identifier.hpp | 25 ++++++++----------------- src/kernel/identifier.cpp | 10 ---------- 5 files changed, 16 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 8e1c3263f..9a41a2509 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.860.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.861.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.860_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.861_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.860 +Meevax Lisp System, version 0.3.861 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6d8be1f8e..9ac2f8177 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.860 +0.3.861 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 80af77435..f113c6a1f 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -82,8 +82,8 @@ inline namespace kernel let const& renamed_x = x.is() ? rename(x, local()) : x; let const& renamed_y = y.is() ? rename(y, local()) : y; - return renamed_x.is_also() and renamed_x.as().is_bound() and - renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); + return renamed_x.is_also() and renamed_x.as().is_bound() and + renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); }; auto is_same_free_identifier(const_reference x, const_reference y) -> bool @@ -91,8 +91,8 @@ inline namespace kernel let const& renamed_x = x.is() ? rename(x, local()) : x; let const& renamed_y = y.is() ? rename(y, local()) : y; - return renamed_x.is_also() and renamed_x.as().is_free() and - renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); + return renamed_x.is_also() and renamed_x.as().is_free() and + renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); } auto generate_free_identifier(const_reference x) -> object diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index f6b358645..8b0e8d04a 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -23,23 +23,14 @@ namespace meevax { inline namespace kernel { - struct [[deprecated]] identifier : public virtual pair + struct absolute : public notation { - using pair::pair; - - virtual auto is_bound() const -> bool = 0; - - virtual auto is_free() const -> bool = 0; - - auto symbol() const -> const_reference; - }; + using notation::notation; - auto operator <<(std::ostream &, identifier const&) -> std::ostream &; - - struct absolute : public identifier - , public notation - { - using identifier::identifier; + auto symbol() const -> const_reference + { + return first; + } auto load(const_reference) const -> object override { @@ -55,9 +46,9 @@ inline namespace kernel auto binding() const -> const_reference; - auto is_bound() const -> bool override; + auto is_bound() const -> bool; - auto is_free() const -> bool override; + auto is_free() const -> bool; }; struct keyword : public absolute diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index c928560c9..0aff7abf2 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -22,16 +22,6 @@ namespace meevax { inline namespace kernel { - auto identifier::symbol() const -> const_reference - { - return first; - } - - auto operator <<(std::ostream & os, identifier const& datum) -> std::ostream & - { - return os << underline(datum.symbol()); - } - auto absolute::binding() -> reference { return second; From fa54e020ed391539294d770a9cf300d248ea34af Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 16 Mar 2022 20:10:29 +0900 Subject: [PATCH 040/118] Move struct `absolute` into `notation.hpp` --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 33 -------------------- include/meevax/kernel/notation.hpp | 46 ++++++++++++++++++++++++++++ src/kernel/identifier.cpp | 21 ------------- 5 files changed, 50 insertions(+), 58 deletions(-) diff --git a/README.md b/README.md index 9a41a2509..80077f335 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.861.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.862.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.861_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.862_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.861 +Meevax Lisp System, version 0.3.862 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9ac2f8177..5a04f8461 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.861 +0.3.862 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 8b0e8d04a..2c1d48983 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -23,39 +23,6 @@ namespace meevax { inline namespace kernel { - struct absolute : public notation - { - using notation::notation; - - auto symbol() const -> const_reference - { - return first; - } - - auto load(const_reference) const -> object override - { - return second; - } - - auto mnemonic() const -> meevax::mnemonic override - { - return mnemonic::load_absolute; - } - - auto binding() -> reference; - - auto binding() const -> const_reference; - - auto is_bound() const -> bool; - - auto is_free() const -> bool; - }; - - struct keyword : public absolute - { - using absolute::absolute; - }; - struct syntactic_closure : public virtual pair // ( . e) { using pair::pair; diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 3eec62576..47126dbf2 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -34,6 +34,52 @@ inline namespace kernel virtual auto mnemonic() const -> mnemonic = 0; }; + struct absolute : public notation + { + using notation::notation; + + auto symbol() const -> const_reference + { + return first; + } + + auto load(const_reference) const -> object override + { + return second; + } + + auto mnemonic() const -> meevax::mnemonic override + { + return mnemonic::load_absolute; + } + + auto binding() -> reference + { + return second; + } + + auto binding() const -> const_reference + { + return second; + } + + auto is_bound() const -> bool + { + return not is_free(); + } + + auto is_free() const -> bool + { + // NOTE: See environment::generate_free_identifier + return binding().is() and std::addressof(binding().as()) == this; + } + }; + + struct keyword : public absolute + { + using absolute::absolute; + }; + struct relative : public notation // de_bruijn_index { using notation::notation; diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 0aff7abf2..31dc3bd0b 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -22,27 +22,6 @@ namespace meevax { inline namespace kernel { - auto absolute::binding() -> reference - { - return second; - } - - auto absolute::binding() const -> const_reference - { - return second; - } - - auto absolute::is_bound() const -> bool - { - return not is_free(); - } - - auto absolute::is_free() const -> bool - { - // NOTE: See environment::generate_free_identifier - return binding().is() and std::addressof(binding().as()) == this; - } - auto notate(const_reference variable, const_reference frames) -> object { for (auto outer = std::begin(frames); outer != std::end(frames); ++outer) From 93728fda8c0cefe5caf5ce59d16a2acd58bcaa27 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 16 Mar 2022 20:55:17 +0900 Subject: [PATCH 041/118] Update member function `notation::load` to return rerference Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 3 ++- include/meevax/kernel/list.hpp | 28 ++++++++++++++++++---------- include/meevax/kernel/notation.hpp | 25 ++++++++++++++++--------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 80077f335..80a83919a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.862.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.863.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.862_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.863_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.862 +Meevax Lisp System, version 0.3.863 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 5a04f8461..123b5b49e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.862 +0.3.863 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 2c1d48983..de53be749 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -29,7 +29,8 @@ inline namespace kernel auto symbol() const -> const_reference { - return car(first); + assert(first.is()); + return first.as().symbol(); } auto strip() diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index e14abfaea..950b7e1a2 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -165,17 +165,25 @@ inline namespace kernel return std::forward_as_tuple(car(x), cdr(x)); }; - auto list_tail = [](auto&& x, auto&& k) -> decltype(auto) + template + auto list_tail(T&& x, std::size_t const k) -> const_reference { - if constexpr (std::is_same::type, object>::value) - { - return std::next(std::cbegin(std::forward(x)), static_cast(k.template as())); - } - else - { - return std::next(std::cbegin(std::forward(x)), std::forward(k)); - } - }; + return 0 < k ? list_tail(cdr(x), k - 1) : x; + } + + template + auto list_tail(T&& x, const_reference k) -> decltype(auto) + { + assert(k.is()); + return list_tail(std::forward(x), static_cast(k.as())); + } + + // auto list_tail = [](reference x, const_reference k) -> decltype(auto) + // { + // assert(x.is() or x.is()); + // assert(k.is()); + // return std::next(std::cbegin(x), static_cast(k.template as())); + // }; auto list_ref = [](auto&&... xs) constexpr -> decltype(auto) { diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 47126dbf2..a5cb54e0f 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -20,6 +20,7 @@ #include #include #include +#include namespace meevax { @@ -29,21 +30,27 @@ inline namespace kernel { using pair::pair; - virtual auto load(const_reference) const -> object = 0; + virtual auto load(const_reference) const -> const_reference = 0; + + virtual auto load(const_reference e) -> reference + { + return const_cast(std::as_const(*this).load(e)); + } virtual auto mnemonic() const -> mnemonic = 0; + + virtual auto symbol() const -> const_reference + { + assert(first.is()); + return first; + } }; struct absolute : public notation { using notation::notation; - auto symbol() const -> const_reference - { - return first; - } - - auto load(const_reference) const -> object override + auto load(const_reference) const -> const_reference override { return second; } @@ -84,7 +91,7 @@ inline namespace kernel { using notation::notation; - auto load(const_reference e) const -> object override + auto load(const_reference e) const -> const_reference override { return list_ref(list_ref(e, m()), n()); } @@ -109,7 +116,7 @@ inline namespace kernel { using relative::relative; - auto load(const_reference e) const -> object override + auto load(const_reference e) const -> const_reference override { return list_tail(list_ref(e, m()), n()); } From 2a02ec28e2e099909a9986c2c1d6cf4b83a8907c Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 16 Mar 2022 21:09:16 +0900 Subject: [PATCH 042/118] Rename member function `notation::load` to `strip` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 2 +- include/meevax/kernel/machine.hpp | 2 +- include/meevax/kernel/notation.hpp | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 80a83919a..56e6f1db7 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.863.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.864.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.863_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.864_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.863 +Meevax Lisp System, version 0.3.864 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 123b5b49e..7bf4bbe97 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.863 +0.3.864 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index de53be749..c8296bc3c 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -35,7 +35,7 @@ inline namespace kernel auto strip() { - return first.as().load(second); + return first.as().strip(second); } auto is_bound() const -> bool diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index f8a3b0fc8..bbaae065e 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -321,7 +321,7 @@ inline namespace kernel * x = (list-tail (list-ref E i) j) * * ------------------------------------------------------------------- */ - s = cons(cadr(c).template as().load(e), s); + s = cons(cadr(c).template as().strip(e), s); c = cddr(c); goto decode; diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index a5cb54e0f..c6f23d6eb 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -30,11 +30,11 @@ inline namespace kernel { using pair::pair; - virtual auto load(const_reference) const -> const_reference = 0; + virtual auto strip(const_reference) const -> const_reference = 0; - virtual auto load(const_reference e) -> reference + virtual auto strip(const_reference e) -> reference { - return const_cast(std::as_const(*this).load(e)); + return const_cast(std::as_const(*this).strip(e)); } virtual auto mnemonic() const -> mnemonic = 0; @@ -50,7 +50,7 @@ inline namespace kernel { using notation::notation; - auto load(const_reference) const -> const_reference override + auto strip(const_reference) const -> const_reference override { return second; } @@ -91,7 +91,7 @@ inline namespace kernel { using notation::notation; - auto load(const_reference e) const -> const_reference override + auto strip(const_reference e) const -> const_reference override { return list_ref(list_ref(e, m()), n()); } @@ -116,7 +116,7 @@ inline namespace kernel { using relative::relative; - auto load(const_reference e) const -> const_reference override + auto strip(const_reference e) const -> const_reference override { return list_tail(list_ref(e, m()), n()); } From 8ee2b64e313c8d7f9ae2e44daf128954b2ebcf15 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 16 Mar 2022 23:59:43 +0900 Subject: [PATCH 043/118] Remove member function `absolute::binding` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 2 +- include/meevax/kernel/machine.hpp | 12 ++++++------ include/meevax/kernel/notation.hpp | 15 +++++---------- src/kernel/environment.cpp | 2 +- 6 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 56e6f1db7..17e4e3b7a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.864.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.865.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.864_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.865_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.864 +Meevax Lisp System, version 0.3.865 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7bf4bbe97..ced61a268 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.864 +0.3.865 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index f113c6a1f..74178a388 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -101,7 +101,7 @@ inline namespace kernel let const result = make(x); - result.as().binding() = result; // NOTE: Identifier is self-evaluate if is free-identifier. + result.as().strip() = result; // NOTE: Identifier is self-evaluate if is free-identifier. assert(result.as().is_free()); diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index bbaae065e..f556da694 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -204,15 +204,15 @@ inline namespace kernel } else if (let const& notation = std::as_const(current_environment).notate(car(expression), frames); notation.is()) { - assert(notation.as().binding().is()); + assert(notation.as().strip().is()); return compile(context::none, current_environment, - notation.as().binding().as().macroexpand(notation.as().binding(), cdr(expression)), + notation.as().strip().as().macroexpand(notation.as().strip(), cdr(expression)), frames, current_continuation); } - else if (let const& applicant = notation.is() ? notation.as().binding() : car(expression); applicant.is_also()) + else if (let const& applicant = notation.is() ? notation.as().strip() : car(expression); applicant.is_also()) { return applicant.as().transform(current_context, current_environment, @@ -405,7 +405,7 @@ inline namespace kernel * where = ( . x := x') * * ------------------------------------------------------------------- */ - cadr(c).template as().binding() = car(s); + cadr(c).template as().strip() = car(s); c = cddr(c); goto decode; @@ -432,7 +432,7 @@ inline namespace kernel // PRINT(keyword_); // PRINT(keyword_.is()); - let & binding = keyword_.as().binding(); + let & binding = keyword_.as().strip(); binding = environment(static_cast(*this)).execute(binding); @@ -719,7 +719,7 @@ inline namespace kernel { if (let const& notation = std::as_const(current_environment).notate(car(form), frames); notation.is()) { - if (let const& callee = notation.as().binding(); callee.is()) + if (let const& callee = notation.as().strip(); callee.is()) { return callee.as().name == "define"; } diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index c6f23d6eb..9ebc0f990 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -50,24 +50,19 @@ inline namespace kernel { using notation::notation; - auto strip(const_reference) const -> const_reference override + auto strip(const_reference = unit) const -> const_reference override { return second; } - auto mnemonic() const -> meevax::mnemonic override - { - return mnemonic::load_absolute; - } - - auto binding() -> reference + auto strip(const_reference = unit) -> reference override { return second; } - auto binding() const -> const_reference + auto mnemonic() const -> meevax::mnemonic override { - return second; + return mnemonic::load_absolute; } auto is_bound() const -> bool @@ -78,7 +73,7 @@ inline namespace kernel auto is_free() const -> bool { // NOTE: See environment::generate_free_identifier - return binding().is() and std::addressof(binding().as()) == this; + return strip().is() and std::addressof(strip().as()) == this; } }; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 889c69115..f48794bcb 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -22,7 +22,7 @@ inline namespace kernel { auto environment::operator [](const_reference name) -> const_reference { - return notate(name, local()).as().binding(); + return notate(name, local()).as().strip(); } auto environment::operator [](std::string const& name) -> const_reference From 0c6c03a9b30a807c13b659caac6e860938e1d0e3 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 00:16:28 +0900 Subject: [PATCH 044/118] Remove member function `relative::m` and `relative::n` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 2 ++ include/meevax/kernel/notation.hpp | 14 ++------------ 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 17e4e3b7a..f01164cdf 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.865.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.866.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.865_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.866_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.865 +Meevax Lisp System, version 0.3.866 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index ced61a268..55f93619c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.865 +0.3.866 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index c8296bc3c..2e2de191c 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -35,6 +35,7 @@ inline namespace kernel auto strip() { + assert(first.is()); return first.as().strip(second); } @@ -45,6 +46,7 @@ inline namespace kernel auto is_free() const -> bool { + assert(first.is()); return first.is() and first.as().is_free(); } }; diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 9ebc0f990..597278809 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -88,23 +88,13 @@ inline namespace kernel auto strip(const_reference e) const -> const_reference override { - return list_ref(list_ref(e, m()), n()); + return list_ref(list_ref(e, car(second)), cdr(second)); } auto mnemonic() const -> meevax::mnemonic override { return mnemonic::load_relative; } - - auto m() const -> const_reference - { - return car(second); - } - - auto n() const -> const_reference - { - return cdr(second); - } }; struct variadic : public relative // de_bruijn_index @@ -113,7 +103,7 @@ inline namespace kernel auto strip(const_reference e) const -> const_reference override { - return list_tail(list_ref(e, m()), n()); + return list_tail(list_ref(e, car(second)), cdr(second)); } auto mnemonic() const -> meevax::mnemonic override From fe27f772e29d3fd4898d6c28b29115b552d605e2 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 00:53:33 +0900 Subject: [PATCH 045/118] Fix instruction `store-variadic` to work correctly Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/list.hpp | 2 +- include/meevax/kernel/machine.hpp | 29 +++++++++++------------------ include/meevax/kernel/notation.hpp | 2 +- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index f01164cdf..c9184edec 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.866.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.867.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.866_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.867_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.866 +Meevax Lisp System, version 0.3.867 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 55f93619c..a30371b69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.866 +0.3.867 diff --git a/include/meevax/kernel/list.hpp b/include/meevax/kernel/list.hpp index 950b7e1a2..2c459d937 100644 --- a/include/meevax/kernel/list.hpp +++ b/include/meevax/kernel/list.hpp @@ -166,7 +166,7 @@ inline namespace kernel }; template - auto list_tail(T&& x, std::size_t const k) -> const_reference + auto list_tail(T&& x, std::size_t const k) -> T { return 0 < k ? list_tail(cdr(x), k - 1) : x; } diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index f556da694..47c0cec3a 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -296,7 +296,7 @@ inline namespace kernel * * s e (%load-absolute . c) d => (x . s) e c d * - * where = ( . ) + * where = ( . x) * * ------------------------------------------------------------------- */ [[fallthrough]]; @@ -307,7 +307,7 @@ inline namespace kernel * * where = ( i . j) * - * x = (list-ref (list-ref E i) j) + * x = (list-ref (list-ref e i) j) * * ------------------------------------------------------------------- */ [[fallthrough]]; @@ -318,7 +318,7 @@ inline namespace kernel * * where = ( i . j) * - * x = (list-tail (list-ref E i) j) + * x = (list-tail (list-ref e i) j) * * ------------------------------------------------------------------- */ s = cons(cadr(c).template as().strip(e), s); @@ -621,37 +621,30 @@ inline namespace kernel case mnemonic::store_absolute: /* ---------------------------------------- * - * (x . s) e (%store-absolute . c) d => (x' . s) e c d + * (x' . s) e (%store-absolute . c) d => (x' . s) e c d * - * where = ( . x') + * where = ( . x:=x') * * ------------------------------------------------------------------- */ - if (let const& binding = cadr(c); cdr(binding).is()) - { - cdr(binding) = car(s); - } - else - { - cdr(binding) = car(s); - } + cadr(c).template as().strip(e) = car(s); c = cddr(c); goto decode; case mnemonic::store_relative: /* ---------------------------------------- * - * (x . s) e (%store-relative (i . j) . c) d => (x' . s) e c d + * (x . s) e (%store-relative . c) d => (x' . s) e c d * * ------------------------------------------------------------------- */ - car(list_tail(list_ref(e, caadr(c)), cdadr(c))) = car(s); + cadr(c).template as().strip(e) = car(s); c = cddr(c); goto decode; case mnemonic::store_variadic: /* ---------------------------------------- * - * (x . s) e (%store-variadic (i . j) . c) d => (x' . s) e c d + * (x . s) e (%store-variadic . c) d => (x' . s) e c d * * ------------------------------------------------------------------- */ - cdr(list_tail(list_ref(e, caadr(c)), cdadr(c))) = car(s); + cadr(c).template as().strip(e) = car(s); c = cddr(c); goto decode; @@ -706,7 +699,7 @@ inline namespace kernel cadr(expression), frames, cons(notation.is() ? make(mnemonic::store_relative) - : make(mnemonic::store_variadic), cdr(notation), // De Bruijn index + : make(mnemonic::store_variadic), notation, // de Bruijn index current_continuation)); } } diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 597278809..606536fb7 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -82,7 +82,7 @@ inline namespace kernel using absolute::absolute; }; - struct relative : public notation // de_bruijn_index + struct relative : public notation // ( . ) { using notation::notation; From b396b107813e039c855cdb018352047cd24a59a6 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 01:01:18 +0900 Subject: [PATCH 046/118] Update instructions `store_*` to execute same code Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 8 ++------ 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index c9184edec..26d3580ec 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.867.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.868.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.867_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.868_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.867 +Meevax Lisp System, version 0.3.868 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a30371b69..227382ae8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.867 +0.3.868 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 47c0cec3a..c1f351b6f 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -626,18 +626,14 @@ inline namespace kernel * where = ( . x:=x') * * ------------------------------------------------------------------- */ - cadr(c).template as().strip(e) = car(s); - c = cddr(c); - goto decode; + [[fallthrough]]; case mnemonic::store_relative: /* ---------------------------------------- * * (x . s) e (%store-relative . c) d => (x' . s) e c d * * ------------------------------------------------------------------- */ - cadr(c).template as().strip(e) = car(s); - c = cddr(c); - goto decode; + [[fallthrough]]; case mnemonic::store_variadic: /* ---------------------------------------- * From 468d41820d9eeda7cdca1286a99fe3f32e091193 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 01:20:11 +0900 Subject: [PATCH 047/118] Rename member function `notation::mnemonic` to `make_load_instruction` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 4 ++-- include/meevax/kernel/notation.hpp | 14 +++++++------- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 26d3580ec..17840a544 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.868.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.869.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.868_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.869_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.868 +Meevax Lisp System, version 0.3.869 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 227382ae8..cb5700d58 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.868 +0.3.869 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index c1f351b6f..beeb5a1b3 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -193,7 +193,7 @@ inline namespace kernel { let const& n = current_environment.notate(expression, frames); - return cons(make(n.as().mnemonic()), n, + return cons(n.as().make_load_instruction(), n, current_continuation); } else // is @@ -1232,7 +1232,7 @@ inline namespace kernel { // if (car(expression).is_also()) // { - // return cons(make(car(expression).as().mnemonic()), car(expression), + // return cons(car(expression).as().make_load_instruction(), car(expression), // current_continuation); // } // else diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 606536fb7..13e98d83b 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -37,7 +37,7 @@ inline namespace kernel return const_cast(std::as_const(*this).strip(e)); } - virtual auto mnemonic() const -> mnemonic = 0; + virtual auto make_load_instruction() const -> object = 0; virtual auto symbol() const -> const_reference { @@ -60,9 +60,9 @@ inline namespace kernel return second; } - auto mnemonic() const -> meevax::mnemonic override + auto make_load_instruction() const -> object override { - return mnemonic::load_absolute; + return make(mnemonic::load_absolute); } auto is_bound() const -> bool @@ -91,9 +91,9 @@ inline namespace kernel return list_ref(list_ref(e, car(second)), cdr(second)); } - auto mnemonic() const -> meevax::mnemonic override + auto make_load_instruction() const -> object override { - return mnemonic::load_relative; + return make(mnemonic::load_relative); } }; @@ -106,9 +106,9 @@ inline namespace kernel return list_tail(list_ref(e, car(second)), cdr(second)); } - auto mnemonic() const -> meevax::mnemonic override + auto make_load_instruction() const -> object override { - return mnemonic::load_variadic; + return make(mnemonic::load_variadic); } }; } // namespace kernel From 6b94f036c344f44250d565f053b1c756d3a83aea Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 01:36:28 +0900 Subject: [PATCH 048/118] Add new member function `notation::make_store_instruction` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 31 ++++++++---------------------- include/meevax/kernel/notation.hpp | 17 ++++++++++++++++ 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 17840a544..4ae17fd52 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.869.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.870.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.869_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.870_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.869 +Meevax Lisp System, version 0.3.870 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index cb5700d58..7e3fc9468 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.869 +0.3.870 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index beeb5a1b3..ace08dded 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -675,29 +675,14 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (expression.is()) - { - throw syntax_error(make("set!"), expression); - } - else if (let const& notation = current_environment.notate(car(expression), frames); notation.is()) - { - return compile(context::none, - current_environment, - cadr(expression), - frames, - cons(make(mnemonic::store_absolute), notation, - current_continuation)); - } - else - { - return compile(context::none, - current_environment, - cadr(expression), - frames, - cons(notation.is() ? make(mnemonic::store_relative) - : make(mnemonic::store_variadic), notation, // de Bruijn index - current_continuation)); - } + let const& notation = current_environment.notate(car(expression), frames); + + return compile(context::none, + current_environment, + cadr(expression), + frames, + cons(notation.as().make_store_instruction(), notation, + current_continuation)); } static SYNTAX(body) diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 13e98d83b..617064f28 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -39,6 +39,8 @@ inline namespace kernel virtual auto make_load_instruction() const -> object = 0; + virtual auto make_store_instruction() const -> object = 0; + virtual auto symbol() const -> const_reference { assert(first.is()); @@ -65,6 +67,11 @@ inline namespace kernel return make(mnemonic::load_absolute); } + auto make_store_instruction() const -> object override + { + return make(mnemonic::store_absolute); + } + auto is_bound() const -> bool { return not is_free(); @@ -95,6 +102,11 @@ inline namespace kernel { return make(mnemonic::load_relative); } + + auto make_store_instruction() const -> object override + { + return make(mnemonic::store_relative); + } }; struct variadic : public relative // de_bruijn_index @@ -110,6 +122,11 @@ inline namespace kernel { return make(mnemonic::load_variadic); } + + auto make_store_instruction() const -> object override + { + return make(mnemonic::store_variadic); + } }; } // namespace kernel } // namespace meevax From cdfd12987eed4b77f10ce6516d4ca31e4e9a75d4 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Thu, 17 Mar 2022 01:47:26 +0900 Subject: [PATCH 049/118] Lipsticks --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 6 ++-- include/meevax/kernel/notation.hpp | 46 ++++++++++++++-------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 4ae17fd52..034182088 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.870.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.871.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.870_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.871_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.870 +Meevax Lisp System, version 0.3.871 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7e3fc9468..b67b68a5a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.870 +0.3.871 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index 2e2de191c..d7d73453c 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -29,13 +29,13 @@ inline namespace kernel auto symbol() const -> const_reference { - assert(first.is()); + assert(first.is_also()); return first.as().symbol(); } auto strip() { - assert(first.is()); + assert(first.is_also()); return first.as().strip(second); } @@ -46,7 +46,7 @@ inline namespace kernel auto is_free() const -> bool { - assert(first.is()); + assert(first.is_also()); return first.is() and first.as().is_free(); } }; diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 617064f28..258f89f0c 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -30,6 +30,10 @@ inline namespace kernel { using pair::pair; + virtual auto make_load_instruction() const -> object = 0; + + virtual auto make_store_instruction() const -> object = 0; + virtual auto strip(const_reference) const -> const_reference = 0; virtual auto strip(const_reference e) -> reference @@ -37,10 +41,6 @@ inline namespace kernel return const_cast(std::as_const(*this).strip(e)); } - virtual auto make_load_instruction() const -> object = 0; - - virtual auto make_store_instruction() const -> object = 0; - virtual auto symbol() const -> const_reference { assert(first.is()); @@ -52,14 +52,15 @@ inline namespace kernel { using notation::notation; - auto strip(const_reference = unit) const -> const_reference override + auto is_bound() const -> bool { - return second; + return not is_free(); } - auto strip(const_reference = unit) -> reference override + auto is_free() const -> bool { - return second; + // NOTE: See environment::generate_free_identifier + return strip().is() and std::addressof(strip().as()) == this; } auto make_load_instruction() const -> object override @@ -72,15 +73,14 @@ inline namespace kernel return make(mnemonic::store_absolute); } - auto is_bound() const -> bool + auto strip(const_reference = unit) const -> const_reference override { - return not is_free(); + return second; } - auto is_free() const -> bool + auto strip(const_reference = unit) -> reference override { - // NOTE: See environment::generate_free_identifier - return strip().is() and std::addressof(strip().as()) == this; + return second; } }; @@ -93,11 +93,6 @@ inline namespace kernel { using notation::notation; - auto strip(const_reference e) const -> const_reference override - { - return list_ref(list_ref(e, car(second)), cdr(second)); - } - auto make_load_instruction() const -> object override { return make(mnemonic::load_relative); @@ -107,17 +102,17 @@ inline namespace kernel { return make(mnemonic::store_relative); } + + auto strip(const_reference e) const -> const_reference override + { + return list_ref(list_ref(e, car(second)), cdr(second)); + } }; struct variadic : public relative // de_bruijn_index { using relative::relative; - auto strip(const_reference e) const -> const_reference override - { - return list_tail(list_ref(e, car(second)), cdr(second)); - } - auto make_load_instruction() const -> object override { return make(mnemonic::load_variadic); @@ -127,6 +122,11 @@ inline namespace kernel { return make(mnemonic::store_variadic); } + + auto strip(const_reference e) const -> const_reference override + { + return list_tail(list_ref(e, car(second)), cdr(second)); + } }; } // namespace kernel } // namespace meevax From 2c46ec3572366bccb2407acf97223101781b0b40 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 02:01:09 +0900 Subject: [PATCH 050/118] Add member function `environment::reserve` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 11 +++++++++-- src/kernel/environment.cpp | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 034182088..4cc9ba795 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.871.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.873.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.871_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.873_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.871 +Meevax Lisp System, version 0.3.873 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b67b68a5a..1abad9418 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.871 +0.3.873 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 74178a388..e32609118 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -95,7 +95,7 @@ inline namespace kernel renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); } - auto generate_free_identifier(const_reference x) -> object + auto reserve(const_reference x) -> const_reference { assert(is_renamable(x)); @@ -105,7 +105,14 @@ inline namespace kernel assert(result.as().is_free()); - return result; + global() = cons(result, global()); + + return car(global()); + } + + auto generate_free_identifier(const_reference x) -> object + { + return make(reserve(x), global()); } auto global() noexcept -> reference; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index f48794bcb..ff7fc2be2 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -184,7 +184,7 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - return car(global() = cons(generate_free_identifier(variable), global())); + return reserve(variable); } } From 3e40dd718b210afb832f255f5dae14c494ff2c19 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 02:59:47 +0900 Subject: [PATCH 051/118] Update member function `environment::define` to return nothing Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 10 +++++----- src/kernel/environment.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 4cc9ba795..f95d2223c 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.873.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.874.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.873_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.874_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.873 +Meevax Lisp System, version 0.3.874 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1abad9418..c611acd7f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.873 +0.3.874 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index e32609118..ba7b6f9f4 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -61,14 +61,14 @@ inline namespace kernel auto operator [](std::string const&) -> const_reference; - auto define(const_reference, const_reference) -> const_reference; + auto define(const_reference, const_reference) -> void; - auto define(std::string const&, const_reference) -> const_reference; + auto define(std::string const&, const_reference) -> void; template - auto define(std::string const& name, Ts&&... xs) -> const_reference + auto define(std::string const& name, Ts&&... xs) -> void { - return define(intern(name), make(name, std::forward(xs)...)); + define(intern(name), make(name, std::forward(xs)...)); } auto evaluate(const_reference) -> object; @@ -112,7 +112,7 @@ inline namespace kernel auto generate_free_identifier(const_reference x) -> object { - return make(reserve(x), global()); + return make(reserve(x), e); } auto global() noexcept -> reference; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index ff7fc2be2..17f77665e 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -30,16 +30,16 @@ inline namespace kernel return (*this)[intern(name)]; } - auto environment::define(const_reference name, const_reference value) -> const_reference + auto environment::define(const_reference name, const_reference value) -> void { assert(name.is()); - return global() = make(name, value) | global(); + global() = make(name, value) | global(); } - auto environment::define(std::string const& name, const_reference value) -> const_reference + auto environment::define(std::string const& name, const_reference value) -> void { - return define(intern(name), value); + define(intern(name), value); } auto environment::evaluate(const_reference expression) -> object /* ---------- From 0daad540ecb42cb7aea47ab567a15293af5ec639 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 03:17:16 +0900 Subject: [PATCH 052/118] Rename variable `frames` to `syntactic_environment` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/machine.hpp | 126 +++++++++--------- .../meevax/kernel/syntactic_continuation.hpp | 2 +- include/meevax/kernel/syntax.hpp | 2 +- src/kernel/environment.cpp | 8 +- src/kernel/identifier.cpp | 8 +- 7 files changed, 79 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index f95d2223c..8f9f66d67 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.874.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.875.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.874_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.875_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.874 +Meevax Lisp System, version 0.3.875 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index c611acd7f..71d61a2c6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.874 +0.3.875 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index ace08dded..59067b419 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -75,7 +75,7 @@ inline namespace kernel c = compile(context::outermost, *this, cadr(base.c).template as().expression(), - cadr(base.c).template as().frames()); + cadr(base.c).template as().syntactic_environment()); d = base.d; spec = environment::execute(); @@ -164,7 +164,7 @@ inline namespace kernel context const current_context, environment & current_environment, const_reference expression, - const_reference frames = unit, + const_reference current_syntactic_environment = unit, const_reference current_continuation = list(make(mnemonic::stop))) -> object { if (expression.is()) /* -------------------------------------------- @@ -191,7 +191,7 @@ inline namespace kernel { if (expression.is() or expression.is_also()) { - let const& n = current_environment.notate(expression, frames); + let const& n = current_environment.notate(expression, current_syntactic_environment); return cons(n.as().make_load_instruction(), n, current_continuation); @@ -202,14 +202,14 @@ inline namespace kernel current_continuation); } } - else if (let const& notation = std::as_const(current_environment).notate(car(expression), frames); notation.is()) + else if (let const& notation = std::as_const(current_environment).notate(car(expression), current_syntactic_environment); notation.is()) { assert(notation.as().strip().is()); return compile(context::none, current_environment, notation.as().strip().as().macroexpand(notation.as().strip(), cdr(expression)), - frames, + current_syntactic_environment, current_continuation); } else if (let const& applicant = notation.is() ? notation.as().strip() : car(expression); applicant.is_also()) @@ -217,7 +217,7 @@ inline namespace kernel return applicant.as().transform(current_context, current_environment, cdr(expression), - frames, + current_syntactic_environment, current_continuation); } else if (applicant.is()) @@ -225,7 +225,7 @@ inline namespace kernel return compile(context::none, current_environment, applicant.as().macroexpand(applicant, cdr(expression)), - frames, + current_syntactic_environment, current_continuation); } else /* ------------------------------------------------------------------ @@ -268,11 +268,11 @@ inline namespace kernel return operand(context::none, current_environment, cdr(expression), - frames, + current_syntactic_environment, compile(context::none, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_continuation))); } @@ -421,13 +421,13 @@ inline namespace kernel // let const& expression = cadr(c).template as().expression(); // PRINT(expression); - let const& frames = cadr(c).template as().frames(); - // PRINT(frames); + let const& syntactic_environment = cadr(c).template as().syntactic_environment(); + // PRINT(syntactic_environment); - // PRINT(car(frames)); - // PRINT(cdr(frames)); + // PRINT(car(syntactic_environment)); + // PRINT(cdr(syntactic_environment)); - for (let const& keyword_ : car(frames)) + for (let const& keyword_ : car(syntactic_environment)) { // PRINT(keyword_); // PRINT(keyword_.is()); @@ -447,7 +447,7 @@ inline namespace kernel body(context::none, static_cast(*this), cadr(c).template as().expression(), - cadr(c).template as().frames(), + cadr(c).template as().syntactic_environment(), cddr(c) ).template as()); goto decode; @@ -468,14 +468,14 @@ inline namespace kernel env.execute(compile(context::outermost, env, cons(make("define-syntax", define_syntax), transformer_spec), - cadr(c).template as().frames())); + cadr(c).template as().syntactic_environment())); } std::swap(c.as(), machine::body(context::outermost, env, body, - cadr(c).template as().frames(), + cadr(c).template as().syntactic_environment(), cddr(c) ).template as()); }(); @@ -675,12 +675,12 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - let const& notation = current_environment.notate(car(expression), frames); + let const& notation = current_environment.notate(car(expression), current_syntactic_environment); return compile(context::none, current_environment, cadr(expression), - frames, + current_syntactic_environment, cons(notation.as().make_store_instruction(), notation, current_continuation)); } @@ -691,7 +691,7 @@ inline namespace kernel { if (form.is()) { - if (let const& notation = std::as_const(current_environment).notate(car(form), frames); notation.is()) + if (let const& notation = std::as_const(current_environment).notate(car(form), current_syntactic_environment); notation.is()) { if (let const& callee = notation.as().strip(); callee.is()) { @@ -741,7 +741,7 @@ inline namespace kernel return compile(current_context | context::tail, current_environment, car(expression), - frames, + current_syntactic_environment, current_continuation); } else if (auto const& [binding_specs, body] = sweep(expression); binding_specs) @@ -759,7 +759,7 @@ inline namespace kernel unzip1(binding_specs), append(map(curry(cons)(make("set!", set)), binding_specs), body)), make_list(length(binding_specs), undefined_object)), - frames, + current_syntactic_environment, current_continuation); } else @@ -767,12 +767,12 @@ inline namespace kernel return compile(current_context, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(mnemonic::drop), begin(current_context, current_environment, cdr(expression), - frames, + current_syntactic_environment, current_continuation))); } } @@ -789,7 +789,7 @@ inline namespace kernel compile(current_context, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(mnemonic::call), current_continuation))); } @@ -816,7 +816,7 @@ inline namespace kernel compile(context::tail, current_environment, cadr(expression), - frames, + current_syntactic_environment, list(make(mnemonic::return_))); auto alternate = @@ -824,7 +824,7 @@ inline namespace kernel ? compile(context::tail, current_environment, caddr(expression), - frames, + current_syntactic_environment, list(make(mnemonic::return_))) : list(make(mnemonic::load_constant), unspecified_object, make(mnemonic::return_)); @@ -832,7 +832,7 @@ inline namespace kernel return compile(context::none, current_environment, car(expression), // - frames, + current_syntactic_environment, cons(make(mnemonic::tail_select), consequent, alternate, cdr(current_continuation))); } @@ -842,7 +842,7 @@ inline namespace kernel compile(context::none, current_environment, cadr(expression), - frames, + current_syntactic_environment, list(make(mnemonic::join))); auto alternate = @@ -850,7 +850,7 @@ inline namespace kernel ? compile(context::none, current_environment, caddr(expression), - frames, + current_syntactic_environment, list(make(mnemonic::join))) : list(make(mnemonic::load_constant), unspecified_object, make(mnemonic::join)); @@ -858,7 +858,7 @@ inline namespace kernel return compile(context::none, current_environment, car(expression), // - frames, + current_syntactic_environment, cons(make(mnemonic::select), consequent, alternate, current_continuation)); } @@ -869,11 +869,11 @@ inline namespace kernel return compile(context::none, current_environment, cadr(expression), - frames, + current_syntactic_environment, compile(context::none, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(mnemonic::cons), current_continuation))); } @@ -902,15 +902,15 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (frames.is() or (current_context & context::outermost)) + if (current_syntactic_environment.is() or (current_context & context::outermost)) { if (car(expression).is()) // (define (f . ) ) { return compile(context::none, current_environment, cons(make("lambda", lambda), cdar(expression), cdr(expression)), - frames, - cons(make(mnemonic::define), current_environment.notate(caar(expression), frames), + current_syntactic_environment, + cons(make(mnemonic::define), current_environment.notate(caar(expression), current_syntactic_environment), current_continuation)); } else // (define x ...) @@ -918,8 +918,8 @@ inline namespace kernel return compile(context::none, current_environment, cdr(expression) ? cadr(expression) : unspecified_object, - frames, - cons(make(mnemonic::define), current_environment.notate(car(expression), frames), + current_syntactic_environment, + cons(make(mnemonic::define), current_environment.notate(car(expression), current_syntactic_environment), current_continuation)); } } @@ -983,7 +983,7 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - // if (frames.is() or (current_context & context::outermost)) + // if (current_syntactic_environment.is() or (current_context & context::outermost)) // { // if (car(expression).is()) // (define-syntax ( . ) ) // { @@ -991,8 +991,8 @@ inline namespace kernel // current_environment, // list(make("fork/csc", fork_csc), // cons(make("lambda", lambda), expression)), - // frames, - // cons(make(mnemonic::define_syntax), cons(frames, current_environment.notate(caar(expression))), + // current_syntactic_environment, + // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(caar(expression))), // current_continuation)); // } // else // (define-syntax x ...) @@ -1000,8 +1000,8 @@ inline namespace kernel // return compile(context::none, // current_environment, // cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), - // frames, - // cons(make(mnemonic::define_syntax), cons(frames, current_environment.notate(car(expression))), + // current_syntactic_environment, + // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(car(expression))), // current_continuation)); // } // } @@ -1019,7 +1019,7 @@ inline namespace kernel cons(make("lambda", lambda), expression) ) ), - frames, + current_syntactic_environment, current_continuation); } else @@ -1027,7 +1027,7 @@ inline namespace kernel return define(current_context, current_environment, expression, - frames, + current_syntactic_environment, current_continuation); } } @@ -1043,7 +1043,7 @@ inline namespace kernel * ----------------------------------------------------------------------- */ { return cons(make(mnemonic::fork), - make(car(expression), frames), + make(car(expression), current_syntactic_environment), current_continuation); } @@ -1075,7 +1075,7 @@ inline namespace kernel body(current_context, current_environment, cdr(expression), - cons(car(expression), frames), // Extend lexical environment. + cons(car(expression), current_syntactic_environment), // Extend lexical environment. list(make(mnemonic::return_))), current_continuation); } @@ -1106,13 +1106,13 @@ inline namespace kernel compile(context::outermost, current_environment, cadr(binding), - frames)); + current_syntactic_environment)); }; auto const [bindings, body] = unpair(expression); return cons(make(mnemonic::let_syntax), - make(body, cons(map(make_keyword, bindings), frames)), + make(body, cons(map(make_keyword, bindings), current_syntactic_environment)), current_continuation); } @@ -1133,7 +1133,7 @@ inline namespace kernel * ----------------------------------------------------------------------- */ { return cons(make(mnemonic::letrec_syntax), - make(expression, frames), + make(expression, current_syntactic_environment), current_continuation); } @@ -1185,11 +1185,11 @@ inline namespace kernel operand(context::none, current_environment, inits, - cons(variables, frames), + cons(variables, current_syntactic_environment), lambda(context::none, current_environment, cons(variables, cdr(expression)), // ( ) - frames, + current_syntactic_environment, cons(make(mnemonic::letrec), current_continuation)))); } @@ -1240,17 +1240,21 @@ inline namespace kernel return operand(context::none, current_environment, cdr(expression), - frames, + current_syntactic_environment, compile(context::none, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(mnemonic::cons), current_continuation))); } else { - return compile(context::none, current_environment, expression, frames, current_continuation); + return compile(context::none, + current_environment, + expression, + current_syntactic_environment, + current_continuation); } } @@ -1287,7 +1291,7 @@ inline namespace kernel return compile(current_context, current_environment, car(expression), - frames, + current_syntactic_environment, current_continuation); } else @@ -1295,12 +1299,12 @@ inline namespace kernel return compile(context::outermost, current_environment, car(expression), - frames, + current_syntactic_environment, cons(make(mnemonic::drop), begin(context::outermost, current_environment, cdr(expression), - frames, + current_syntactic_environment, current_continuation))); } } @@ -1311,7 +1315,7 @@ inline namespace kernel return compile(current_context, current_environment, car(expression), - frames, + current_syntactic_environment, current_continuation); } else @@ -1319,12 +1323,12 @@ inline namespace kernel return compile(context::none, current_environment, car(expression), // head expression - frames, + current_syntactic_environment, cons(make(mnemonic::drop), // pop result of head expression begin(context::none, current_environment, cdr(expression), // rest expressions - frames, + current_syntactic_environment, current_continuation))); } } diff --git a/include/meevax/kernel/syntactic_continuation.hpp b/include/meevax/kernel/syntactic_continuation.hpp index 172af2640..6dad5224a 100644 --- a/include/meevax/kernel/syntactic_continuation.hpp +++ b/include/meevax/kernel/syntactic_continuation.hpp @@ -32,7 +32,7 @@ inline namespace kernel return first; } - auto frames() const -> const_reference + auto syntactic_environment() const -> const_reference { return second; } diff --git a/include/meevax/kernel/syntax.hpp b/include/meevax/kernel/syntax.hpp index aabce807d..6eeb06a87 100644 --- a/include/meevax/kernel/syntax.hpp +++ b/include/meevax/kernel/syntax.hpp @@ -26,7 +26,7 @@ [[maybe_unused]] context const current_context, \ [[maybe_unused]] environment & current_environment, \ [[maybe_unused]] const_reference expression, \ - [[maybe_unused]] const_reference frames, \ + [[maybe_unused]] const_reference current_syntactic_environment, \ [[maybe_unused]] const_reference current_continuation) -> object namespace meevax diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 17f77665e..5076c6cd3 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -141,13 +141,13 @@ inline namespace kernel return first; } - auto environment::notate(const_reference variable, const_reference frames) const -> object + auto environment::notate(const_reference variable, const_reference syntactic_environment) const -> object { if (not is_renamable(variable)) { return f; } - else if (let const& identifier = meevax::notate(variable, frames); select(identifier)) + else if (let const& identifier = meevax::notate(variable, syntactic_environment); select(identifier)) { return identifier; } @@ -157,13 +157,13 @@ inline namespace kernel } } - auto environment::notate(const_reference variable, const_reference frames) -> object + auto environment::notate(const_reference variable, const_reference syntactic_environment) -> object { if (not is_renamable(variable)) { return f; } - if (let const& binding = std::as_const(*this).notate(variable, frames); select(binding)) + if (let const& binding = std::as_const(*this).notate(variable, syntactic_environment); select(binding)) { return binding; } diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index 31dc3bd0b..d8a491b94 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -22,9 +22,9 @@ namespace meevax { inline namespace kernel { - auto notate(const_reference variable, const_reference frames) -> object + auto notate(const_reference variable, const_reference syntactic_environment) -> object { - for (auto outer = std::begin(frames); outer != std::end(frames); ++outer) + for (auto outer = std::begin(syntactic_environment); outer != std::end(syntactic_environment); ++outer) { for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) { @@ -35,13 +35,13 @@ inline namespace kernel else if (inner.is() and eq(*inner, variable)) { return make(variable, - cons(make(std::distance(std::begin(frames), outer)), + cons(make(std::distance(std::begin(syntactic_environment), outer)), make(std::distance(std::begin(*outer), inner)))); } else if (inner.is() and eq(inner, variable)) { return make(variable, - cons(make(std::distance(std::begin(frames), outer)), + cons(make(std::distance(std::begin(syntactic_environment), outer)), make(std::distance(std::begin(*outer), inner)))); } } From 8aa1f72d9a52b8e238d5d021ced7f1906b62521b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 03:29:16 +0900 Subject: [PATCH 053/118] Rename member function `environment::is_renamable` to `is_identifier` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 4 ++-- src/kernel/environment.cpp | 16 ++++++++-------- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8f9f66d67..40dccf517 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.875.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.876.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.875_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.876_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.875 +Meevax Lisp System, version 0.3.876 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 71d61a2c6..60019075d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.875 +0.3.876 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index ba7b6f9f4..ccb9ebc10 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -97,7 +97,7 @@ inline namespace kernel auto reserve(const_reference x) -> const_reference { - assert(is_renamable(x)); + assert(is_identifier(x)); let const result = make(x); @@ -124,7 +124,7 @@ inline namespace kernel auto import() -> void; - static auto is_renamable(const_reference) -> bool; + static auto is_identifier(const_reference) -> bool; auto load(std::string const&) -> object; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 5076c6cd3..61ccec4a9 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -32,7 +32,7 @@ inline namespace kernel auto environment::define(const_reference name, const_reference value) -> void { - assert(name.is()); + assert(is_identifier(name)); global() = make(name, value) | global(); } @@ -109,7 +109,7 @@ inline namespace kernel define("set-verbose!", [this](let const& xs, auto&&) { return verbose = car(xs); }); } - auto environment::is_renamable(const_reference x) -> bool + auto environment::is_identifier(const_reference x) -> bool { return x.is() or x.is_also() or x.is(); } @@ -143,13 +143,13 @@ inline namespace kernel auto environment::notate(const_reference variable, const_reference syntactic_environment) const -> object { - if (not is_renamable(variable)) + if (not is_identifier(variable)) { return f; } - else if (let const& identifier = meevax::notate(variable, syntactic_environment); select(identifier)) + else if (let const& notation = meevax::notate(variable, syntactic_environment); select(notation)) { - return identifier; + return notation; } else { @@ -159,13 +159,13 @@ inline namespace kernel auto environment::notate(const_reference variable, const_reference syntactic_environment) -> object { - if (not is_renamable(variable)) + if (not is_identifier(variable)) { return f; } - if (let const& binding = std::as_const(*this).notate(variable, syntactic_environment); select(binding)) + if (let const& notation = std::as_const(*this).notate(variable, syntactic_environment); select(notation)) { - return binding; + return notation; } else /* -------------------------------------------------------------------- * From 161c59ad3facad741dff83fb1fe42a17616fa543 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 03:36:03 +0900 Subject: [PATCH 054/118] Rename member function `environment::local` to `syntactic_environment` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 12 ++++++------ include/meevax/kernel/machine.hpp | 4 ++-- src/kernel/environment.cpp | 8 ++++---- src/library/meevax.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 40dccf517..ae8fb08eb 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.876.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.877.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.876_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.877_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.876 +Meevax Lisp System, version 0.3.877 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 60019075d..6823e1c5e 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.876 +0.3.877 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index ccb9ebc10..a455a7d4b 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -79,8 +79,8 @@ inline namespace kernel auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool { - let const& renamed_x = x.is() ? rename(x, local()) : x; - let const& renamed_y = y.is() ? rename(y, local()) : y; + let const& renamed_x = x.is() ? rename(x, syntactic_environment()) : x; + let const& renamed_y = y.is() ? rename(y, syntactic_environment()) : y; return renamed_x.is_also() and renamed_x.as().is_bound() and renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); @@ -88,8 +88,8 @@ inline namespace kernel auto is_same_free_identifier(const_reference x, const_reference y) -> bool { - let const& renamed_x = x.is() ? rename(x, local()) : x; - let const& renamed_y = y.is() ? rename(y, local()) : y; + let const& renamed_x = x.is() ? rename(x, syntactic_environment()) : x; + let const& renamed_y = y.is() ? rename(y, syntactic_environment()) : y; return renamed_x.is_also() and renamed_x.as().is_free() and renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); @@ -128,9 +128,9 @@ inline namespace kernel auto load(std::string const&) -> object; - auto local() const noexcept -> const_reference; + auto syntactic_environment() const noexcept -> const_reference; - auto local() noexcept -> reference; + auto syntactic_environment() noexcept -> reference; auto notate(const_reference, const_reference) -> object; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 59067b419..01ec53e02 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -40,7 +40,7 @@ inline namespace kernel {} IMPORT(environment, global, const); - IMPORT(environment, local, ); + IMPORT(environment, syntactic_environment, ); protected: let s, // stack (holding intermediate results and return address) @@ -361,7 +361,7 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - s = cons(make(local(), global()), s); + s = cons(make(syntactic_environment(), global()), s); car(s).template as().build(static_cast(*this)); c = cddr(c); goto decode; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 61ccec4a9..6e85de5d9 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -22,7 +22,7 @@ inline namespace kernel { auto environment::operator [](const_reference name) -> const_reference { - return notate(name, local()).as().strip(); + return notate(name, syntactic_environment()).as().strip(); } auto environment::operator [](std::string const& name) -> const_reference @@ -53,7 +53,7 @@ inline namespace kernel * ------------------------------------------------------------------------- */ { d = cons(s, e, c, d); - c = compile(context::none, *this, expression, local()); + c = compile(context::none, *this, expression, syntactic_environment()); e = unit; s = unit; @@ -131,12 +131,12 @@ inline namespace kernel } } - auto environment::local() const noexcept -> const_reference + auto environment::syntactic_environment() const noexcept -> const_reference { return first; } - auto environment::local() noexcept -> reference + auto environment::syntactic_environment() noexcept -> reference { return first; } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index c664dd9ed..795d68ba4 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1916,7 +1916,7 @@ namespace meevax define("identifier?", [](let const& xs, auto&&) { - return is_renamable(car(xs)) ? t : f; + return is_identifier(car(xs)) ? t : f; }); /* ------------------------------------------------------------------------- From 63c51eb8073f8e6cf0f26afef7949a30f2e18613 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 03:44:50 +0900 Subject: [PATCH 055/118] Rename member function `environment::global` to `global_environment` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 8 ++++---- include/meevax/kernel/machine.hpp | 4 ++-- src/kernel/environment.cpp | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ae8fb08eb..75ddad3b0 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.877.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.878.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.877_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.878_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.877 +Meevax Lisp System, version 0.3.878 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6823e1c5e..f964fb6c9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.877 +0.3.878 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index a455a7d4b..06a9060fd 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -105,9 +105,9 @@ inline namespace kernel assert(result.as().is_free()); - global() = cons(result, global()); + global_environment() = cons(result, global_environment()); - return car(global()); + return car(global_environment()); } auto generate_free_identifier(const_reference x) -> object @@ -115,9 +115,9 @@ inline namespace kernel return make(reserve(x), e); } - auto global() noexcept -> reference; + auto global_environment() noexcept -> reference; - auto global() const noexcept -> const_reference; + auto global_environment() const noexcept -> const_reference; template auto import(std::integer_sequence) -> void; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 01ec53e02..752e09b82 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -39,7 +39,7 @@ inline namespace kernel machine() {} - IMPORT(environment, global, const); + IMPORT(environment, global_environment, const); IMPORT(environment, syntactic_environment, ); protected: @@ -361,7 +361,7 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - s = cons(make(syntactic_environment(), global()), s); + s = cons(make(syntactic_environment(), global_environment()), s); car(s).template as().build(static_cast(*this)); c = cddr(c); goto decode; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 6e85de5d9..1aebe9459 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -34,7 +34,7 @@ inline namespace kernel { assert(is_identifier(name)); - global() = make(name, value) | global(); + global_environment() = make(name, value) | global_environment(); } auto environment::define(std::string const& name, const_reference value) -> void @@ -89,12 +89,12 @@ inline namespace kernel return execute(); } - auto environment::global() const noexcept -> const_reference + auto environment::global_environment() const noexcept -> const_reference { return second; } - auto environment::global() noexcept -> reference + auto environment::global_environment() noexcept -> reference { return second; } @@ -153,7 +153,7 @@ inline namespace kernel } else { - return assq(variable, global()); + return assq(variable, global_environment()); } } From 05cf0eaccc0875db1b54cef3f6fd3627b2404f48 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 19 Mar 2022 22:06:26 +0900 Subject: [PATCH 056/118] Rename variable `expression` to `current_expression` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/machine.hpp | 137 +++++++++++++++--------------- include/meevax/kernel/syntax.hpp | 6 +- 4 files changed, 76 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 75ddad3b0..eda8779d5 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.878.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.879.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.878_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.879_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.878 +Meevax Lisp System, version 0.3.879 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f964fb6c9..cf9936d01 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.878 +0.3.879 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 752e09b82..cae32db58 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -163,11 +163,11 @@ inline namespace kernel static auto compile( context const current_context, environment & current_environment, - const_reference expression, + const_reference current_expression, const_reference current_syntactic_environment = unit, const_reference current_continuation = list(make(mnemonic::stop))) -> object { - if (expression.is()) /* -------------------------------------------- + if (current_expression.is()) /* ------------------------------------ * * ( ...) syntax * @@ -178,7 +178,7 @@ inline namespace kernel { return cons(make(mnemonic::load_constant), unit, current_continuation); } - else if (not expression.is()) /* ----------------------------------- + else if (not current_expression.is()) /* ----------------------------------- * * syntax * @@ -189,34 +189,35 @@ inline namespace kernel * * --------------------------------------------------------------------- */ { - if (expression.is() or expression.is_also()) + if (current_expression.is() or current_expression.is_also()) { - let const& n = current_environment.notate(expression, current_syntactic_environment); + let const& n = current_environment.notate(current_expression, + current_syntactic_environment); return cons(n.as().make_load_instruction(), n, current_continuation); } else // is { - return cons(make(mnemonic::load_constant), expression, + return cons(make(mnemonic::load_constant), current_expression, current_continuation); } } - else if (let const& notation = std::as_const(current_environment).notate(car(expression), current_syntactic_environment); notation.is()) + else if (let const& notation = std::as_const(current_environment).notate(car(current_expression), current_syntactic_environment); notation.is()) { assert(notation.as().strip().is()); return compile(context::none, current_environment, - notation.as().strip().as().macroexpand(notation.as().strip(), cdr(expression)), + notation.as().strip().as().macroexpand(notation.as().strip(), cdr(current_expression)), current_syntactic_environment, current_continuation); } - else if (let const& applicant = notation.is() ? notation.as().strip() : car(expression); applicant.is_also()) + else if (let const& applicant = notation.is() ? notation.as().strip() : car(current_expression); applicant.is_also()) { return applicant.as().transform(current_context, current_environment, - cdr(expression), + cdr(current_expression), current_syntactic_environment, current_continuation); } @@ -224,7 +225,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().macroexpand(applicant, cdr(expression)), + applicant.as().macroexpand(applicant, cdr(current_expression)), current_syntactic_environment, current_continuation); } @@ -267,11 +268,11 @@ inline namespace kernel { return operand(context::none, current_environment, - cdr(expression), + cdr(current_expression), current_syntactic_environment, compile(context::none, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_continuation))); @@ -675,11 +676,11 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - let const& notation = current_environment.notate(car(expression), current_syntactic_environment); + let const& notation = current_environment.notate(car(current_expression), current_syntactic_environment); return compile(context::none, current_environment, - cadr(expression), + cadr(current_expression), current_syntactic_environment, cons(notation.as().make_store_instruction(), notation, current_continuation)); @@ -736,15 +737,15 @@ inline namespace kernel where = * * */ - if (cdr(expression).is()) // is tail-sequence + if (cdr(current_expression).is()) // is tail-sequence { return compile(current_context | context::tail, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, current_continuation); } - else if (auto const& [binding_specs, body] = sweep(expression); binding_specs) + else if (auto const& [binding_specs, body] = sweep(current_expression); binding_specs) { /* (letrec* ) @@ -766,12 +767,12 @@ inline namespace kernel { return compile(current_context, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(mnemonic::drop), begin(current_context, current_environment, - cdr(expression), + cdr(current_expression), current_syntactic_environment, current_continuation))); } @@ -788,7 +789,7 @@ inline namespace kernel current_continuation, compile(current_context, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(mnemonic::call), current_continuation))); @@ -815,15 +816,15 @@ inline namespace kernel auto consequent = compile(context::tail, current_environment, - cadr(expression), + cadr(current_expression), current_syntactic_environment, list(make(mnemonic::return_))); auto alternate = - cddr(expression) + cddr(current_expression) ? compile(context::tail, current_environment, - caddr(expression), + caddr(current_expression), current_syntactic_environment, list(make(mnemonic::return_))) : list(make(mnemonic::load_constant), unspecified_object, @@ -831,7 +832,7 @@ inline namespace kernel return compile(context::none, current_environment, - car(expression), // + car(current_expression), // current_syntactic_environment, cons(make(mnemonic::tail_select), consequent, alternate, cdr(current_continuation))); @@ -841,15 +842,15 @@ inline namespace kernel auto consequent = compile(context::none, current_environment, - cadr(expression), + cadr(current_expression), current_syntactic_environment, list(make(mnemonic::join))); auto alternate = - cddr(expression) + cddr(current_expression) ? compile(context::none, current_environment, - caddr(expression), + caddr(current_expression), current_syntactic_environment, list(make(mnemonic::join))) : list(make(mnemonic::load_constant), unspecified_object, @@ -857,7 +858,7 @@ inline namespace kernel return compile(context::none, current_environment, - car(expression), // + car(current_expression), // current_syntactic_environment, cons(make(mnemonic::select), consequent, alternate, current_continuation)); @@ -868,11 +869,11 @@ inline namespace kernel { return compile(context::none, current_environment, - cadr(expression), + cadr(current_expression), current_syntactic_environment, compile(context::none, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(mnemonic::cons), current_continuation))); } @@ -904,22 +905,22 @@ inline namespace kernel { if (current_syntactic_environment.is() or (current_context & context::outermost)) { - if (car(expression).is()) // (define (f . ) ) + if (car(current_expression).is()) // (define (f . ) ) { return compile(context::none, current_environment, - cons(make("lambda", lambda), cdar(expression), cdr(expression)), + cons(make("lambda", lambda), cdar(current_expression), cdr(current_expression)), current_syntactic_environment, - cons(make(mnemonic::define), current_environment.notate(caar(expression), current_syntactic_environment), + cons(make(mnemonic::define), current_environment.notate(caar(current_expression), current_syntactic_environment), current_continuation)); } else // (define x ...) { return compile(context::none, current_environment, - cdr(expression) ? cadr(expression) : unspecified_object, + cdr(current_expression) ? cadr(current_expression) : unspecified_object, current_syntactic_environment, - cons(make(mnemonic::define), current_environment.notate(car(expression), current_syntactic_environment), + cons(make(mnemonic::define), current_environment.notate(car(current_expression), current_syntactic_environment), current_continuation)); } } @@ -985,23 +986,23 @@ inline namespace kernel { // if (current_syntactic_environment.is() or (current_context & context::outermost)) // { - // if (car(expression).is()) // (define-syntax ( . ) ) + // if (car(current_expression).is()) // (define-syntax ( . ) ) // { // return compile(context::none, // current_environment, // list(make("fork/csc", fork_csc), - // cons(make("lambda", lambda), expression)), + // cons(make("lambda", lambda), current_expression)), // current_syntactic_environment, - // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(caar(expression))), + // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(caar(current_expression))), // current_continuation)); // } // else // (define-syntax x ...) // { // return compile(context::none, // current_environment, - // cdr(expression) ? cadr(expression) : throw syntax_error(make("define-syntax: no specified")), + // cdr(current_expression) ? cadr(current_expression) : throw syntax_error(make("define-syntax: no specified")), // current_syntactic_environment, - // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(car(expression))), + // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(car(current_expression))), // current_continuation)); // } // } @@ -1010,13 +1011,13 @@ inline namespace kernel // throw syntax_error(make("definition cannot appear in this syntactic-context")); // } - if (car(expression).is()) // (define-syntax ( . xs) ) + if (car(current_expression).is()) // (define-syntax ( . xs) ) { return define(current_context, current_environment, - list(caar(expression), + list(caar(current_expression), list(make("fork/csc", fork_csc), - cons(make("lambda", lambda), expression) + cons(make("lambda", lambda), current_expression) ) ), current_syntactic_environment, @@ -1026,7 +1027,7 @@ inline namespace kernel { return define(current_context, current_environment, - expression, + current_expression, current_syntactic_environment, current_continuation); } @@ -1043,7 +1044,7 @@ inline namespace kernel * ----------------------------------------------------------------------- */ { return cons(make(mnemonic::fork), - make(car(expression), current_syntactic_environment), + make(car(current_expression), current_syntactic_environment), current_continuation); } @@ -1074,8 +1075,8 @@ inline namespace kernel return cons(make(mnemonic::load_closure), body(current_context, current_environment, - cdr(expression), - cons(car(expression), current_syntactic_environment), // Extend lexical environment. + cdr(current_expression), + cons(car(current_expression), current_syntactic_environment), // Extend lexical environment. list(make(mnemonic::return_))), current_continuation); } @@ -1109,7 +1110,7 @@ inline namespace kernel current_syntactic_environment)); }; - auto const [bindings, body] = unpair(expression); + auto const [bindings, body] = unpair(current_expression); return cons(make(mnemonic::let_syntax), make(body, cons(map(make_keyword, bindings), current_syntactic_environment)), @@ -1133,7 +1134,7 @@ inline namespace kernel * ----------------------------------------------------------------------- */ { return cons(make(mnemonic::letrec_syntax), - make(expression, current_syntactic_environment), + make(current_expression, current_syntactic_environment), current_continuation); } @@ -1179,7 +1180,7 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - auto const& [variables, inits] = unzip2(car(expression)); + auto const& [variables, inits] = unzip2(car(current_expression)); return cons(make(mnemonic::dummy), operand(context::none, @@ -1188,7 +1189,7 @@ inline namespace kernel cons(variables, current_syntactic_environment), lambda(context::none, current_environment, - cons(variables, cdr(expression)), // ( ) + cons(variables, cdr(current_expression)), // ( ) current_syntactic_environment, cons(make(mnemonic::letrec), current_continuation)))); @@ -1215,35 +1216,35 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - // if (car(expression).is_also()) + // if (car(current_expression).is_also()) // { - // return cons(car(expression).as().make_load_instruction(), car(expression), + // return cons(car(current_expression).as().make_load_instruction(), car(current_expression), // current_continuation); // } // else // { - return cons(make(mnemonic::load_constant), car(expression), + return cons(make(mnemonic::load_constant), car(current_expression), current_continuation); // } } static SYNTAX(quote_syntax) { - return cons(make(mnemonic::load_constant), car(expression), + return cons(make(mnemonic::load_constant), car(current_expression), current_continuation); } static SYNTAX(operand) { - if (expression.is()) + if (current_expression.is()) { return operand(context::none, current_environment, - cdr(expression), + cdr(current_expression), current_syntactic_environment, compile(context::none, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(mnemonic::cons), current_continuation))); @@ -1252,7 +1253,7 @@ inline namespace kernel { return compile(context::none, current_environment, - expression, + current_expression, current_syntactic_environment, current_continuation); } @@ -1286,11 +1287,11 @@ inline namespace kernel { if (current_context & context::outermost) { - if (cdr(expression).is()) + if (cdr(current_expression).is()) { return compile(current_context, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, current_continuation); } @@ -1298,23 +1299,23 @@ inline namespace kernel { return compile(context::outermost, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, cons(make(mnemonic::drop), begin(context::outermost, current_environment, - cdr(expression), + cdr(current_expression), current_syntactic_environment, current_continuation))); } } else { - if (cdr(expression).is()) // is tail sequence + if (cdr(current_expression).is()) // is tail sequence { return compile(current_context, current_environment, - car(expression), + car(current_expression), current_syntactic_environment, current_continuation); } @@ -1322,12 +1323,12 @@ inline namespace kernel { return compile(context::none, current_environment, - car(expression), // head expression + car(current_expression), // head expression current_syntactic_environment, cons(make(mnemonic::drop), // pop result of head expression begin(context::none, current_environment, - cdr(expression), // rest expressions + cdr(current_expression), // rest expressions current_syntactic_environment, current_continuation))); } diff --git a/include/meevax/kernel/syntax.hpp b/include/meevax/kernel/syntax.hpp index 6eeb06a87..a7f1402fe 100644 --- a/include/meevax/kernel/syntax.hpp +++ b/include/meevax/kernel/syntax.hpp @@ -23,9 +23,9 @@ #define SYNTAX(NAME) \ auto NAME( \ - [[maybe_unused]] context const current_context, \ - [[maybe_unused]] environment & current_environment, \ - [[maybe_unused]] const_reference expression, \ + [[maybe_unused]] context const current_context, \ + [[maybe_unused]] environment & current_environment, \ + [[maybe_unused]] const_reference current_expression, \ [[maybe_unused]] const_reference current_syntactic_environment, \ [[maybe_unused]] const_reference current_continuation) -> object From d11caebefa941fba8214c41d1d2a9bdc9ec10443 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 21 Mar 2022 00:59:14 +0900 Subject: [PATCH 057/118] Add experimental procedure `identifier` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 18 ++++++++++-------- src/library/meevax.cpp | 6 ++++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index eda8779d5..6069926da 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.879.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.880.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.879_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.880_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.879 +Meevax Lisp System, version 0.3.880 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index cf9936d01..b5a97a15c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.879 +0.3.880 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 06a9060fd..c26d490c5 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -79,8 +79,8 @@ inline namespace kernel auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool { - let const& renamed_x = x.is() ? rename(x, syntactic_environment()) : x; - let const& renamed_y = y.is() ? rename(y, syntactic_environment()) : y; + let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; + let const& renamed_y = y.is() ? notate(y, syntactic_environment()) : y; return renamed_x.is_also() and renamed_x.as().is_bound() and renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); @@ -88,8 +88,8 @@ inline namespace kernel auto is_same_free_identifier(const_reference x, const_reference y) -> bool { - let const& renamed_x = x.is() ? rename(x, syntactic_environment()) : x; - let const& renamed_y = y.is() ? rename(y, syntactic_environment()) : y; + let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; + let const& renamed_y = y.is() ? notate(y, syntactic_environment()) : y; return renamed_x.is_also() and renamed_x.as().is_free() and renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); @@ -136,14 +136,16 @@ inline namespace kernel auto notate(const_reference, const_reference) const -> object; - auto rename(const_reference symbol, const_reference syntactic_environment) -> object + template + auto rename(Ts&&... xs) { - return notate(symbol, syntactic_environment); + return make(notate(std::forward(xs)...), e); } - auto rename(const_reference symbol, const_reference syntactic_environment) const -> object + template + auto rename(Ts&&... xs) const { - return notate(symbol, syntactic_environment); + return make(notate(std::forward(xs)...), e); } }; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 795d68ba4..9297507db 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1899,6 +1899,12 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { + define("identifier", [](let const& xs, auto & environment) + { + assert(car(xs).is()); + return environment.rename(car(xs), environment.syntactic_environment()); + }); + /* ------------------------------------------------------------------------- * * (identifier? syntax-object) procedure From 57d68ecd36497e0ba52bfacc2f6781f982cc2542 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 21 Mar 2022 13:19:13 +0900 Subject: [PATCH 058/118] Move free function `notate` into struct `machine` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/identifier.hpp | 2 -- include/meevax/kernel/machine.hpp | 28 ++++++++++++++++++++++++++++ src/kernel/environment.cpp | 2 +- src/kernel/identifier.cpp | 27 --------------------------- 6 files changed, 33 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 6069926da..76cd10658 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.880.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.882.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.880_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.882_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.880 +Meevax Lisp System, version 0.3.882 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b5a97a15c..a2ab8f87a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.880 +0.3.882 diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/identifier.hpp index d7d73453c..01f7b6dc1 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/identifier.hpp @@ -50,8 +50,6 @@ inline namespace kernel return first.is() and first.as().is_free(); } }; - - auto notate(const_reference, const_reference) -> object; } // namespace kernel } // namespace meevax diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index cae32db58..de7e91c60 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -655,6 +655,34 @@ inline namespace kernel } } + static auto notate(const_reference variable, const_reference syntactic_environment) -> object + { + for (auto outer = std::begin(syntactic_environment); outer != std::end(syntactic_environment); ++outer) + { + for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) + { + if (inner.is() and (*inner).is() and eq((*inner).as().symbol(), variable)) + { + return *inner; + } + else if (inner.is() and eq(*inner, variable)) + { + return make(variable, + cons(make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(*outer), inner)))); + } + else if (inner.is() and eq(inner, variable)) + { + return make(variable, + cons(make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(*outer), inner)))); + } + } + } + + return f; + } + inline auto reset() -> void { s = unit; diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 1aebe9459..0b79674dc 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -147,7 +147,7 @@ inline namespace kernel { return f; } - else if (let const& notation = meevax::notate(variable, syntactic_environment); select(notation)) + else if (let const& notation = machine::notate(variable, syntactic_environment); select(notation)) { return notation; } diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp index d8a491b94..1e11e34bb 100644 --- a/src/kernel/identifier.cpp +++ b/src/kernel/identifier.cpp @@ -22,32 +22,5 @@ namespace meevax { inline namespace kernel { - auto notate(const_reference variable, const_reference syntactic_environment) -> object - { - for (auto outer = std::begin(syntactic_environment); outer != std::end(syntactic_environment); ++outer) - { - for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) - { - if (inner.is() and (*inner).is() and eq((*inner).as().symbol(), variable)) - { - return *inner; - } - else if (inner.is() and eq(*inner, variable)) - { - return make(variable, - cons(make(std::distance(std::begin(syntactic_environment), outer)), - make(std::distance(std::begin(*outer), inner)))); - } - else if (inner.is() and eq(inner, variable)) - { - return make(variable, - cons(make(std::distance(std::begin(syntactic_environment), outer)), - make(std::distance(std::begin(*outer), inner)))); - } - } - } - - return f; - } } // namespace kernel } // namespace meevax From 798aecd54875ae9fa946262715d42ddd1913b98d Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 21 Mar 2022 13:30:50 +0900 Subject: [PATCH 059/118] Rename header `identifier.hpp` to `syntactic_closure.hpp` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 2 +- .../{identifier.hpp => syntactic_closure.hpp} | 6 ++--- src/kernel/identifier.cpp | 26 ------------------- 5 files changed, 8 insertions(+), 34 deletions(-) rename include/meevax/kernel/{identifier.hpp => syntactic_closure.hpp} (89%) delete mode 100644 src/kernel/identifier.cpp diff --git a/README.md b/README.md index 76cd10658..a5a7ed3ab 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.882.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.883.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.882_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.883_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.882 +Meevax Lisp System, version 0.3.883 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a2ab8f87a..72d456d69 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.882 +0.3.883 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index de7e91c60..0c43deaba 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -20,10 +20,10 @@ #include #include #include -#include #include #include #include +#include #include #include diff --git a/include/meevax/kernel/identifier.hpp b/include/meevax/kernel/syntactic_closure.hpp similarity index 89% rename from include/meevax/kernel/identifier.hpp rename to include/meevax/kernel/syntactic_closure.hpp index 01f7b6dc1..bd8307ba4 100644 --- a/include/meevax/kernel/identifier.hpp +++ b/include/meevax/kernel/syntactic_closure.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP -#define INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP +#ifndef INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP +#define INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP #include @@ -53,4 +53,4 @@ inline namespace kernel } // namespace kernel } // namespace meevax -#endif // INCLUDED_MEEVAX_KERNEL_IDENTIFIER_HPP +#endif // INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP diff --git a/src/kernel/identifier.cpp b/src/kernel/identifier.cpp deleted file mode 100644 index 1e11e34bb..000000000 --- a/src/kernel/identifier.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - Copyright 2018-2022 Tatsuya Yamasaki. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#include -#include -#include - -namespace meevax -{ -inline namespace kernel -{ -} // namespace kernel -} // namespace meevax From 76bd02981ec5500bdc6c599fd4cf280564bca0cf Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 21 Mar 2022 13:45:02 +0900 Subject: [PATCH 060/118] Cleanup member function `machine::notate` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 14 ++++++++++---- include/meevax/kernel/notation.hpp | 4 ++-- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index a5a7ed3ab..d401f1d20 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.883.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.884.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.883_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.884_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.883 +Meevax Lisp System, version 0.3.884 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 72d456d69..cd177ee9b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.883 +0.3.884 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 0c43deaba..297c1d4ff 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -667,15 +667,21 @@ inline namespace kernel } else if (inner.is() and eq(*inner, variable)) { + // NOTE: A class that inherits from pair behaves as if it were `cons*` when given three or more arguments. + static_assert(std::is_base_of::value); + return make(variable, - cons(make(std::distance(std::begin(syntactic_environment), outer)), - make(std::distance(std::begin(*outer), inner)))); + make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(*outer), inner))); } else if (inner.is() and eq(inner, variable)) { + // NOTE: A class that inherits from pair behaves as if it were `cons*` when given three or more arguments. + static_assert(std::is_base_of::value); + return make(variable, - cons(make(std::distance(std::begin(syntactic_environment), outer)), - make(std::distance(std::begin(*outer), inner)))); + make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(*outer), inner))); } } } diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index 258f89f0c..a10f49b4f 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -89,7 +89,7 @@ inline namespace kernel using absolute::absolute; }; - struct relative : public notation // ( . ) + struct relative : public notation // ( . ) = ( . ) { using notation::notation; @@ -109,7 +109,7 @@ inline namespace kernel } }; - struct variadic : public relative // de_bruijn_index + struct variadic : public relative // ( . ) = ( . ) { using relative::relative; From 44f7c2edf2c254aef1e98a4cb23fb7fdc8b36012 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Mar 2022 23:15:01 +0900 Subject: [PATCH 061/118] Add new test script `identifier.ss` Signed-off-by: yamacir-kit --- CMakeLists.txt | 1 + README.md | 6 +++--- VERSION | 2 +- src/library/meevax.cpp | 2 +- test/identifier.ss | 17 +++++++++++++++++ 5 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 test/identifier.ss diff --git a/CMakeLists.txt b/CMakeLists.txt index 11983e60d..dafcd539f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,6 +166,7 @@ endmacro() check(abandoned) check(chibi-basic) check(er-macro-transformer) +check(identifier) check(internal-definition) check(let-syntax) check(letrec-syntax) diff --git a/README.md b/README.md index d401f1d20..c70f3536f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.884.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.885.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.884_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.885_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.884 +Meevax Lisp System, version 0.3.885 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index cd177ee9b..7533b71df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.884 +0.3.885 diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 9297507db..160178fd2 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2000,7 +2000,7 @@ namespace meevax switch (length(xs)) { case 1: - if (let const& x = car(xs); x.is_also()) + if (let const& x = car(xs); x.is()) { return x.as().symbol(); } diff --git a/test/identifier.ss b/test/identifier.ss new file mode 100644 index 000000000..93087a725 --- /dev/null +++ b/test/identifier.ss @@ -0,0 +1,17 @@ +(define value 42) + +; ------------------------------------------------------------------------------ + +(check (identifier? (identifier 'value)) => #t) + +(check (identifier? 'value) => #t) + +(check (identifier? 3) => #f) + +; ------------------------------------------------------------------------------ + +(check (identifier->symbol (identifier 'value)) => value) + +(check-report) + +(exit (check-passed? check:correct)) From ee257fdb38bb5486467352dfd66cbe8cf9b8531f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Mar 2022 23:25:39 +0900 Subject: [PATCH 062/118] Rename syntax `construction` to `cons_` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 2 +- src/library/meevax.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index c70f3536f..768113a19 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.885.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.886.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.885_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.886_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.885 +Meevax Lisp System, version 0.3.886 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7533b71df..593d7a41d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.885 +0.3.886 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 297c1d4ff..2c3cda3fd 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -899,7 +899,7 @@ inline namespace kernel } } - static SYNTAX(construction) + static SYNTAX(cons_) { return compile(context::none, current_environment, diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 160178fd2..bfb34e4bc 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -405,7 +405,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("cons", construction, [](let const& xs, auto&&) + define("cons", cons_, [](let const& xs, auto&&) { return cons(car(xs), cadr(xs)); }); From 11cca3561485edf49940683d39576ec01f81b970 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 22 Mar 2022 23:34:48 +0900 Subject: [PATCH 063/118] Rename struct `syntactic_procedure` to `instruction_level_procedure` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- ...ocedure.hpp => instruction_level_procedure.hpp} | 14 +++++++------- include/meevax/kernel/machine.hpp | 2 +- ...ocedure.cpp => instruction_level_procedure.cpp} | 4 ++-- src/library/meevax.cpp | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) rename include/meevax/kernel/{syntactic_procedure.hpp => instruction_level_procedure.hpp} (66%) rename src/kernel/{syntactic_procedure.cpp => instruction_level_procedure.cpp} (82%) diff --git a/README.md b/README.md index 768113a19..0d9d499e3 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.886.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.887.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.886_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.887_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.886 +Meevax Lisp System, version 0.3.887 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 593d7a41d..5f419a194 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.886 +0.3.887 diff --git a/include/meevax/kernel/syntactic_procedure.hpp b/include/meevax/kernel/instruction_level_procedure.hpp similarity index 66% rename from include/meevax/kernel/syntactic_procedure.hpp rename to include/meevax/kernel/instruction_level_procedure.hpp index 099b588e5..58d875f5f 100644 --- a/include/meevax/kernel/syntactic_procedure.hpp +++ b/include/meevax/kernel/instruction_level_procedure.hpp @@ -14,8 +14,8 @@ limitations under the License. */ -#ifndef INCLUDED_MEEVAX_KERNEL_SYNTACTIC_PROCEDURE_HPP -#define INCLUDED_MEEVAX_KERNEL_SYNTACTIC_PROCEDURE_HPP +#ifndef INCLUDED_MEEVAX_KERNEL_INSTRUCTION_LEVEL_PROCEDURE_HPP +#define INCLUDED_MEEVAX_KERNEL_INSTRUCTION_LEVEL_PROCEDURE_HPP #include #include @@ -24,18 +24,18 @@ namespace meevax { inline namespace kernel { - struct syntactic_procedure : public syntax - , public procedure + struct instruction_level_procedure : public syntax + , public procedure { template - explicit syntactic_procedure(std::string const& name, F&& f, G&& g) + explicit instruction_level_procedure(std::string const& name, F&& f, G&& g) : syntax { name, std::forward(f) } , procedure { name, std::forward(g) } {} }; - auto operator <<(std::ostream &, syntactic_procedure const&) -> std::ostream &; + auto operator <<(std::ostream &, instruction_level_procedure const&) -> std::ostream &; } // namespace kernel } // namespace meevax -#endif // INCLUDED_MEEVAX_KERNEL_SYNTACTIC_PROCEDURE_HPP +#endif // INCLUDED_MEEVAX_KERNEL_INSTRUCTION_LEVEL_PROCEDURE_HPP diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 2c3cda3fd..69eb22195 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -21,11 +21,11 @@ #include #include #include +#include #include #include #include #include -#include namespace meevax { diff --git a/src/kernel/syntactic_procedure.cpp b/src/kernel/instruction_level_procedure.cpp similarity index 82% rename from src/kernel/syntactic_procedure.cpp rename to src/kernel/instruction_level_procedure.cpp index bd4b7260e..db51c3192 100644 --- a/src/kernel/syntactic_procedure.cpp +++ b/src/kernel/instruction_level_procedure.cpp @@ -14,13 +14,13 @@ limitations under the License. */ -#include +#include namespace meevax { inline namespace kernel { - auto operator <<(std::ostream & os, syntactic_procedure const& datum) -> std::ostream & + auto operator <<(std::ostream & os, instruction_level_procedure const& datum) -> std::ostream & { return os << static_cast(datum); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index bfb34e4bc..400d3be1e 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -405,7 +405,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("cons", cons_, [](let const& xs, auto&&) + define("cons", cons_, [](let const& xs, auto&&) { return cons(car(xs), cadr(xs)); }); From 5e8c443eb83e0d2e7bc67677d4cc0bdad98c8023 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 2 Apr 2022 16:17:48 +0900 Subject: [PATCH 064/118] Add experimental builtin transformer `er_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/machine.hpp | 51 ++++++++++++++++++++++++++++++ include/meevax/kernel/notation.hpp | 5 +++ src/library/meevax.cpp | 10 ++++++ test/er-macro-transformer.ss | 23 ++++++++++++++ 6 files changed, 93 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0d9d499e3..82e89813a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.887.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.890.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.887_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.890_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.887 +Meevax Lisp System, version 0.3.890 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 5f419a194..a507c5791 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.887 +0.3.890 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 69eb22195..918c99628 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -138,6 +138,48 @@ inline namespace kernel } }; + struct er_macro_transformer // explicit-renaming + { + let const transform; + + environment expander; + + explicit er_macro_transformer(let const& transform, environment const& current_environment) + : transform { transform } + , expander { current_environment } + { + assert(transform.is()); + + expander.reset(); + } + + auto expand(let const& form, environment & receiver) + { + auto rename = make("rename", [](let const& xs, auto&& expander) + { + // return expander.rename(car(xs), expander.syntactic_environment()); + return expander.evaluate(car(xs)); + }); + + auto compare = make("compare", [](let const& xs, auto&&) + { + return eqv(car(xs), cadr(xs)) ? t : f; + }); + + expander.s = list(transform, + list(form, rename, compare)); + expander.c = list(make(mnemonic::call), + make(mnemonic::stop)); + + return expander.execute(); + } + + friend auto operator <<(std::ostream & os, er_macro_transformer const& datum) -> std::ostream & + { + return os << magenta("#,(") << green("er-macro-transformer ") << faint("#;", &datum) << magenta(")"); + } + }; + public: /* ---- R7RS 4. Expressions ------------------------------------------------ * @@ -229,6 +271,15 @@ inline namespace kernel current_syntactic_environment, current_continuation); } + else if (applicant.is()) + { + return compile(context::none, + current_environment, + applicant.as().expand(current_expression, + current_environment), + current_syntactic_environment, + current_continuation); + } else /* ------------------------------------------------------------------ * * ( ...) syntax diff --git a/include/meevax/kernel/notation.hpp b/include/meevax/kernel/notation.hpp index a10f49b4f..099bea094 100644 --- a/include/meevax/kernel/notation.hpp +++ b/include/meevax/kernel/notation.hpp @@ -46,6 +46,11 @@ inline namespace kernel assert(first.is()); return first; } + + friend auto operator <<(std::ostream & os, notation const& datum) -> std::ostream & + { + return os << "#,(notation " << datum.symbol() << ")"; + } }; struct absolute : public notation diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 400d3be1e..1e73ce1d6 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1899,6 +1899,16 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { + define("%er-macro-transformer", [](let const& xs, auto & current_environment) + { + return make(car(xs), current_environment); + }); + + define("er-macro-transformer?", [](let const& xs, auto&&) + { + return car(xs).is() ? t : f; + }); + define("identifier", [](let const& xs, auto & environment) { assert(car(xs).is()); diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index 96da55efb..e47023880 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -55,6 +55,29 @@ ; ------------------------------------------------------------------------------ +(define-syntax swap! + (%er-macro-transformer + (lambda (form rename compare) + (let ((a (cadr form)) + (b (caddr form))) + `(,(rename 'let) ((,(rename 'x) ,a)) + (,(rename 'set!) ,a ,b) + (,(rename 'set!) ,b ,(rename 'x))))))) + +(check (er-macro-transformer? swap!) => #t) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +(swap! x y) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ + (check-report) (exit (check-passed? check:correct)) From a3ac82aabb0c1229eb510585695ff201b45231d4 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 2 Apr 2022 16:37:21 +0900 Subject: [PATCH 065/118] Update `transformer::macroexpand` to receive form Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 9 ++++----- src/library/meevax.cpp | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 82e89813a..534ad36bf 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.890.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.891.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.890_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.891_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.890 +Meevax Lisp System, version 0.3.891 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a507c5791..e1f96fab3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.890 +0.3.891 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 918c99628..a55e63464 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -83,8 +83,7 @@ inline namespace kernel environment::reset(); } - template - auto macroexpand(Ts&&... xs) /* ------------------------------------------ + auto macroexpand(let const& form) /* ------------------------------------- * * Scheme programs can define and use new derived expression types, * called macros. Program-defined expression types have the syntax @@ -126,7 +125,7 @@ inline namespace kernel assert(car(c).template as().value == mnemonic::stop); assert(cdr(c).template is()); - s = list(spec, cons(std::forward(xs)...)); + s = list(spec, form); c = cons(make(mnemonic::call), c); return environment::execute(); @@ -251,7 +250,7 @@ inline namespace kernel return compile(context::none, current_environment, - notation.as().strip().as().macroexpand(notation.as().strip(), cdr(current_expression)), + notation.as().strip().as().macroexpand(cons(notation.as().strip(), cdr(current_expression))), current_syntactic_environment, current_continuation); } @@ -267,7 +266,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().macroexpand(applicant, cdr(current_expression)), + applicant.as().macroexpand(cons(applicant, cdr(current_expression))), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 1e73ce1d6..ce7755e1a 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2070,7 +2070,7 @@ namespace meevax { if (let const& macro = (*this)[caar(xs)]; macro.is()) { - return macro.as().macroexpand(macro, car(xs)); + return macro.as().macroexpand(cons(macro, car(xs))); } else { From e1704925239726fc88447386f97eb05a14d622b8 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 2 Apr 2022 17:49:07 +0900 Subject: [PATCH 066/118] Add new member function `environment::apply` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 4 +++- include/meevax/kernel/machine.hpp | 12 ++-------- src/kernel/environment.cpp | 33 +++++++++++++++++++++------ 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 534ad36bf..2cb1298bc 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.891.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.892.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.891_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.892_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.891 +Meevax Lisp System, version 0.3.892 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index e1f96fab3..9cd0ed5dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.891 +0.3.892 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index c26d490c5..9242263b9 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -61,6 +61,8 @@ inline namespace kernel auto operator [](std::string const&) -> const_reference; + auto apply(const_reference, const_reference) -> object; + auto define(const_reference, const_reference) -> void; auto define(std::string const&, const_reference) -> void; @@ -105,7 +107,7 @@ inline namespace kernel assert(result.as().is_free()); - global_environment() = cons(result, global_environment()); + global_environment() = result | global_environment(); return car(global_environment()); } diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index a55e63464..3aa748e8a 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -125,10 +125,7 @@ inline namespace kernel assert(car(c).template as().value == mnemonic::stop); assert(cdr(c).template is()); - s = list(spec, form); - c = cons(make(mnemonic::call), c); - - return environment::execute(); + return environment::apply(spec, form); } friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & @@ -165,12 +162,7 @@ inline namespace kernel return eqv(car(xs), cadr(xs)) ? t : f; }); - expander.s = list(transform, - list(form, rename, compare)); - expander.c = list(make(mnemonic::call), - make(mnemonic::stop)); - - return expander.execute(); + return expander.apply(transform, list(form, rename, compare)); } friend auto operator <<(std::ostream & os, er_macro_transformer const& datum) -> std::ostream & diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 0b79674dc..764fb473a 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -30,6 +30,24 @@ inline namespace kernel return (*this)[intern(name)]; } + auto environment::apply(const_reference f, const_reference xs) -> object + { + auto dump = std::make_tuple(std::exchange(s, list(f, xs)), + std::exchange(e, unit), + std::exchange(c, list(make(mnemonic::call), + make(mnemonic::stop))), + std::exchange(d, unit)); + + let const result = execute(); + + s = std::get<0>(dump); + e = std::get<1>(dump); + c = std::get<2>(dump); + d = std::get<3>(dump); + + return result; + } + auto environment::define(const_reference name, const_reference value) -> void { assert(is_identifier(name)); @@ -52,10 +70,10 @@ inline namespace kernel * * ------------------------------------------------------------------------- */ { - d = cons(s, e, c, d); - c = compile(context::none, *this, expression, syntactic_environment()); - e = unit; - s = unit; + auto dump = std::make_tuple(std::exchange(s, unit), + std::exchange(e, unit), + std::exchange(c, compile(context::none, *this, expression, syntactic_environment())), + std::exchange(d, unit)); if (is_debug_mode()) { @@ -64,9 +82,10 @@ inline namespace kernel let const result = execute(); - s = pop(d); - e = pop(d); - c = pop(d); + s = std::get<0>(dump); + e = std::get<1>(dump); + c = std::get<2>(dump); + d = std::get<3>(dump); return result; } From c991c3220d138e2b6c0a0713273eb01ded8e5926 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 2 Apr 2022 17:53:04 +0900 Subject: [PATCH 067/118] Rename member function `transformer::macroexpand` to `expand` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 20 ++++++++++---------- src/library/meevax.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2cb1298bc..d43ce92be 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.892.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.893.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.892_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.893_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.892 +Meevax Lisp System, version 0.3.893 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9cd0ed5dd..f4ea76448 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.892 +0.3.893 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 3aa748e8a..7f8c5911b 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -83,7 +83,7 @@ inline namespace kernel environment::reset(); } - auto macroexpand(let const& form) /* ------------------------------------- + auto expand(let const& form) /* ------------------------------------------ * * Scheme programs can define and use new derived expression types, * called macros. Program-defined expression types have the syntax @@ -104,13 +104,13 @@ inline namespace kernel * instruction in the dump register (this stop instruction is preset by * the constructor of the transformer). * - * NOTE: transformer::macroexpand is never called recursively. This is - * because in the normal macro expansion performed by machine::compile, - * control is returned to machine::compile each time the macro is - * expanded one step. As an exception, there are cases where this - * transformer is given to the eval procedure as an - * , but there is no problem because the stack - * control at that time is performed by environment::evaluate. + * NOTE: transformer::expand is never called recursively. This is because + * in the normal macro expansion performed by machine::compile, control + * is returned to machine::compile each time the macro is expanded one + * step. As an exception, there are cases where this transformer is given + * to the eval procedure as an , but there is no + * problem because the stack control at that time is performed by + * environment::evaluate. * * --------------------------------------------------------------------- */ { @@ -242,7 +242,7 @@ inline namespace kernel return compile(context::none, current_environment, - notation.as().strip().as().macroexpand(cons(notation.as().strip(), cdr(current_expression))), + notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), current_syntactic_environment, current_continuation); } @@ -258,7 +258,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().macroexpand(cons(applicant, cdr(current_expression))), + applicant.as().expand(cons(applicant, cdr(current_expression))), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index ce7755e1a..c3f8e5dcb 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2070,7 +2070,7 @@ namespace meevax { if (let const& macro = (*this)[caar(xs)]; macro.is()) { - return macro.as().macroexpand(cons(macro, car(xs))); + return macro.as().expand(cons(macro, car(xs))); } else { From a72a27df7854f18b3b3f4ae5adb28bd4614b124c Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 2 Apr 2022 22:47:54 +0900 Subject: [PATCH 068/118] Update struct `transformer`'s constructor to receive `environment` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/machine.hpp | 57 +++++++++++-------------------- src/library/meevax.cpp | 2 +- 4 files changed, 25 insertions(+), 42 deletions(-) diff --git a/README.md b/README.md index d43ce92be..39390f1ea 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.893.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.894.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.893_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.894_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.893 +Meevax Lisp System, version 0.3.894 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f4ea76448..1e75598ee 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.893 +0.3.894 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 7f8c5911b..5cf0e23b2 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -48,39 +48,23 @@ inline namespace kernel c, // code (instructions yet to be executed) d; // dump (s e c . d) - struct transformer : public environment + struct transformer { - using environment::s; - using environment::e; - using environment::c; - using environment::d; - let spec; - explicit transformer() /* ------------------------------------------------ - * - * Since the base class environment inherits from pair, all arguments - * given to make are forwarded directly to the virtual base - * class pair. After that, the constructor of the base class environment - * is called to set up the environment. This constructor is called after - * them. - * - * --------------------------------------------------------------------- */ - {} + environment expander; - auto build(environment const& base) -> void + explicit transformer(environment const& current_environment) + : expander { current_environment } { - s = base.s; - e = base.e; - c = compile(context::outermost, - *this, - cadr(base.c).template as().expression(), - cadr(base.c).template as().syntactic_environment()); - d = base.d; + expander.c = compile(context::outermost, + expander, + cadr(expander.c).template as().expression(), + cadr(expander.c).template as().syntactic_environment()); - spec = environment::execute(); + spec = expander.execute(); - environment::reset(); + expander.reset(); } auto expand(let const& form) /* ------------------------------------------ @@ -116,16 +100,16 @@ inline namespace kernel { assert(spec.template is()); - assert(d.template is()); - assert(c.template is()); - assert(e.template is()); - assert(s.template is()); + assert(expander.d.template is()); + assert(expander.c.template is()); + assert(expander.e.template is()); + assert(expander.s.template is()); - assert(car(c).template is()); - assert(car(c).template as().value == mnemonic::stop); - assert(cdr(c).template is()); + assert(car(expander.c).template is()); + assert(car(expander.c).template as().value == mnemonic::stop); + assert(cdr(expander.c).template is()); - return environment::apply(spec, form); + return expander.apply(spec, form); } friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & @@ -149,7 +133,7 @@ inline namespace kernel expander.reset(); } - auto expand(let const& form, environment & receiver) + auto expand(let const& form, environment &) { auto rename = make("rename", [](let const& xs, auto&& expander) { @@ -404,8 +388,7 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - s = cons(make(syntactic_environment(), global_environment()), s); - car(s).template as().build(static_cast(*this)); + s = cons(make(static_cast(*this)), s); c = cddr(c); goto decode; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index c3f8e5dcb..040619c7b 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1649,7 +1649,7 @@ namespace meevax define("eval", [](let const& xs, auto&&) { - return cadr(xs).as().evaluate(car(xs)); + return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! }); } From 97725fa1a0f3866145329294cda568bdf720e3df Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 00:05:01 +0900 Subject: [PATCH 069/118] Update `procedure` to receive syntactic-environment as 2nd argument Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 32 ++- include/meevax/kernel/machine.hpp | 33 ++- include/meevax/kernel/procedure.hpp | 6 +- src/kernel/environment.cpp | 14 +- src/kernel/instruction.cpp | 4 +- src/library/meevax.cpp | 286 +++++++++++++------------ test/vector.cpp | 2 +- 9 files changed, 199 insertions(+), 186 deletions(-) diff --git a/README.md b/README.md index 39390f1ea..b979e2b96 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.894.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.895.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.894_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.895_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.894 +Meevax Lisp System, version 0.3.895 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1e75598ee..7b859c747 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.894 +0.3.895 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index e17d1f779..41665e9f5 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -88,17 +88,17 @@ inline namespace kernel , short_options_with_arguments { - std::make_pair('e', [this](const_reference x, auto &&) + std::make_pair('e', [this](const_reference x, auto&&...) { return print(evaluate(x)), unspecified_object; }), - std::make_pair('l', [this](const_reference x, auto &&) + std::make_pair('l', [this](const_reference x, auto&&...) { return load(x.as()); }), - std::make_pair('w', [this](const_reference x, auto &&) + std::make_pair('w', [this](const_reference x, auto&&...) { return print(x), unspecified_object; }), @@ -146,22 +146,22 @@ inline namespace kernel , long_options_with_arguments { - std::make_pair("evaluate", [this](const_reference x, auto &&) + std::make_pair("evaluate", [this](const_reference x, auto&&...) { return print(evaluate(x)), unspecified_object; }), - std::make_pair("load", [this](const_reference x, auto &&) + std::make_pair("load", [this](const_reference x, auto&&...) { return load(x.as()); }), - std::make_pair("prompt", [this](const_reference x, auto &&) + std::make_pair("prompt", [this](const_reference x, auto&&...) { return prompt = x; }), - std::make_pair("write", [this](const_reference x, auto &&) + std::make_pair("write", [this](const_reference x, auto&&...) { return print(x), unspecified_object; }), @@ -205,11 +205,13 @@ inline namespace kernel if (auto const& [name, perform] = *iter; std::next(current_short_option) != std::end(current_short_options)) { return perform(read(std::string(std::next(current_short_option), std::end(current_short_options))), + static_cast(*this).syntactic_environment(), static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { return perform(read(*current_option), + static_cast(*this).syntactic_environment(), static_cast(*this)); } else @@ -219,7 +221,9 @@ inline namespace kernel } else if (auto iter = short_options.find(*current_short_option); iter != std::end(short_options)) { - cdr(*iter)(unit, static_cast(*this)); + cdr(*iter)(unit, + static_cast(*this).syntactic_environment(), + static_cast(*this)); } else { @@ -233,11 +237,15 @@ inline namespace kernel { if (analysis.length(2)) // argument part { - return cdr(*iter)(read(analysis.str(3)), static_cast(*this)); + return cdr(*iter)(read(analysis.str(3)), + static_cast(*this).syntactic_environment(), + static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { - return cdr(*iter)(read(*current_option), static_cast(*this)); + return cdr(*iter)(read(*current_option), + static_cast(*this).syntactic_environment(), + static_cast(*this)); } else { @@ -246,7 +254,9 @@ inline namespace kernel } else if (auto iter = long_options.find(current_long_option); iter != std::end(long_options)) { - return cdr(*iter)(unit, static_cast(*this)); + return cdr(*iter)(unit, + static_cast(*this).syntactic_environment(), + static_cast(*this)); } else { diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 5cf0e23b2..eb9c49fac 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -135,13 +135,13 @@ inline namespace kernel auto expand(let const& form, environment &) { - auto rename = make("rename", [](let const& xs, auto&& expander) + auto rename = make("rename", [](let const& xs, auto&&, auto&& expander) { // return expander.rename(car(xs), expander.syntactic_environment()); return expander.evaluate(car(xs)); }); - auto compare = make("compare", [](let const& xs, auto&&) + auto compare = make("compare", [](let const& xs, let const&, environment &) { return eqv(car(xs), cadr(xs)) ? t : f; }); @@ -250,8 +250,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().expand(current_expression, - current_environment), + applicant.as().expand(current_expression, current_environment), current_syntactic_environment, current_continuation); } @@ -300,7 +299,7 @@ inline namespace kernel current_environment, car(current_expression), current_syntactic_environment, - cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), + cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_syntactic_environment, current_continuation))); } } @@ -510,31 +509,31 @@ inline namespace kernel case mnemonic::call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) + * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) * * where = (c' . e') * * ------------------------------------------------------------------- */ { - d = cons(cddr(s), e, cdr(c), d); + d = cons(cddr(s), e, cddr(c), d); c = callee.as().c(); e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), static_cast(*this)), cddr(s)); - c = cdr(c); + s = cons(callee.as().apply(cadr(s), cadr(c), static_cast(*this)), cddr(s)); + c = cddr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -554,7 +553,7 @@ inline namespace kernel case mnemonic::tail_call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d + * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d * * where = (c' . e') * @@ -566,18 +565,18 @@ inline namespace kernel } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%tail-call . c) d => (x . s) e c d + * ( xs . s) e (%tail-call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), static_cast(*this)), cddr(s)); - c = cdr(c); + s = cons(callee.as().apply(cadr(s), cadr(c), static_cast(*this)), cddr(s)); + c = cddr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%tail-call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%tail-call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -850,7 +849,7 @@ inline namespace kernel current_environment, car(current_expression), current_syntactic_environment, - cons(make(mnemonic::call), + cons(make(mnemonic::call), current_syntactic_environment, current_continuation))); } diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index acfeb3e4a..37b5eb954 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -24,7 +24,9 @@ namespace meevax { inline namespace kernel { - #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs, environment &) + #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs, \ + meevax::const_reference, \ + environment &) struct procedure : public description { @@ -48,7 +50,7 @@ inline namespace kernel template struct is { - auto operator ()(const_reference xs, environment const&) const -> const_reference + auto operator ()(const_reference xs, const_reference, environment const&) const -> const_reference { auto is_T = [](const_reference x) { diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 764fb473a..a67658a78 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -34,7 +34,7 @@ inline namespace kernel { auto dump = std::make_tuple(std::exchange(s, list(f, xs)), std::exchange(e, unit), - std::exchange(c, list(make(mnemonic::call), + std::exchange(c, list(make(mnemonic::call), syntactic_environment(), make(mnemonic::stop))), std::exchange(d, unit)); @@ -120,12 +120,12 @@ inline namespace kernel auto environment::import() -> void { - define("set-batch!", [this](let const& xs, auto&&) { return batch = car(xs); }); - define("set-debug!", [this](let const& xs, auto&&) { return debug = car(xs); }); - define("set-interactive!", [this](let const& xs, auto&&) { return interactive = car(xs); }); - define("set-prompt!", [this](let const& xs, auto&&) { return prompt = car(xs); }); - define("set-trace!", [this](let const& xs, auto&&) { return trace = car(xs); }); - define("set-verbose!", [this](let const& xs, auto&&) { return verbose = car(xs); }); + define("set-batch!", [this](let const& xs, auto&&...) { return batch = car(xs); }); + define("set-debug!", [this](let const& xs, auto&&...) { return debug = car(xs); }); + define("set-interactive!", [this](let const& xs, auto&&...) { return interactive = car(xs); }); + define("set-prompt!", [this](let const& xs, auto&&...) { return prompt = car(xs); }); + define("set-trace!", [this](let const& xs, auto&&...) { return trace = car(xs); }); + define("set-verbose!", [this](let const& xs, auto&&...) { return verbose = car(xs); }); } auto environment::is_identifier(const_reference x) -> bool diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index c54e9b161..431731613 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -85,13 +85,11 @@ inline namespace kernel switch ((*iter).as().value) { - case mnemonic::call: case mnemonic::cons: case mnemonic::drop: case mnemonic::dummy: case mnemonic::join: case mnemonic::letrec: - case mnemonic::tail_call: os << *iter << "\n"; ++offset; break; @@ -102,6 +100,7 @@ inline namespace kernel ++offset; break; + case mnemonic::call: case mnemonic::define: case mnemonic::define_syntax: case mnemonic::fork: @@ -114,6 +113,7 @@ inline namespace kernel case mnemonic::store_absolute: case mnemonic::store_relative: case mnemonic::store_variadic: + case mnemonic::tail_call: os << *iter << " " << *++iter << "\n"; offset += 2; break; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 040619c7b..888caf066 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -49,7 +49,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eqv?", [](let const& xs, auto &&) // TODO Rename to value=? + define("eqv?", [](let const& xs, auto&&...) // TODO Rename to value=? { return eqv(car(xs), cadr(xs)) ? t : f; }); @@ -73,7 +73,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eq?", [](auto&& xs, auto &&) // TODO Rename to reference=? + define("eq?", [](auto&& xs, auto&&...) // TODO Rename to reference=? { return eq(car(xs), cadr(xs)) ? t : f; }); @@ -100,11 +100,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); - define("complex?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_complex () ? t : f; }); - define("real?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_real () ? t : f; }); - define("rational?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); - define("integer?", [](let const& xs, auto&&) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); + define("number?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); + define("complex?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_complex () ? t : f; }); + define("real?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_real () ? t : f; }); + define("rational?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); + define("integer?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); define("%complex?", is()); define("ratio?", is()); @@ -157,7 +157,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, COMPARE) \ - define(#SYMBOL, [](let const& xs, auto &&) \ + define(#SYMBOL, [](let const& xs, auto&&...) \ { \ return std::adjacent_find( \ std::begin(xs), std::end(xs), [](let const& a, let const& b) \ @@ -184,8 +184,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("+", [](let const& xs, auto&&) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); - define("*", [](let const& xs, auto&&) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); + define("+", [](let const& xs, auto&&...) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); + define("*", [](let const& xs, auto&&...) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); /* ------------------------------------------------------------------------- * @@ -206,7 +206,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, FUNCTION, BASIS) \ - define(SYMBOL, [](let const& xs, auto&&) \ + define(SYMBOL, [](let const& xs, auto&&...) \ { \ switch (length(xs)) \ { \ @@ -248,10 +248,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("floor", [](let const& xs, auto&&) { return car(xs).as().floor(); }); - define("ceiling", [](let const& xs, auto&&) { return car(xs).as().ceil(); }); - define("truncate", [](let const& xs, auto&&) { return car(xs).as().trunc(); }); - define("round", [](let const& xs, auto&&) { return car(xs).as().round(); }); + define("floor", [](let const& xs, auto&&...) { return car(xs).as().floor(); }); + define("ceiling", [](let const& xs, auto&&...) { return car(xs).as().ceil(); }); + define("truncate", [](let const& xs, auto&&...) { return car(xs).as().trunc(); }); + define("round", [](let const& xs, auto&&...) { return car(xs).as().round(); }); /* ------------------------------------------------------------------------- * @@ -266,7 +266,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("expt", [](let const& xs, auto&&) + define("expt", [](let const& xs, auto&&...) { return car(xs).as().pow(cadr(xs)); }); @@ -307,8 +307,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "exact", [](let const& xs, auto&&) { return car(xs).as().exact (); }); - define("inexact", [](let const& xs, auto&&) { return car(xs).as().inexact(); }); + define( "exact", [](let const& xs, auto&&...) { return car(xs).as().exact (); }); + define("inexact", [](let const& xs, auto&&...) { return car(xs).as().inexact(); }); /* ------------------------------------------------------------------------- * @@ -347,7 +347,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number->string", [](auto&& xs, auto&&) + define("number->string", [](auto&& xs, auto&&...) { return make(lexical_cast(car(xs))); }); @@ -369,7 +369,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->number", [](let const& xs, auto&&) + define("string->number", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -405,7 +405,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("cons", cons_, [](let const& xs, auto&&) + define("cons", cons_, [](let const& xs, auto&&...) { return cons(car(xs), cadr(xs)); }); @@ -424,8 +424,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("car", [](let const& xs, auto&&) { return caar(xs); }); - define("cdr", [](let const& xs, auto&&) { return cdar(xs); }); + define("car", [](let const& xs, auto&&...) { return caar(xs); }); + define("cdr", [](let const& xs, auto&&...) { return cdar(xs); }); /* ------------------------------------------------------------------------- * @@ -439,8 +439,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("set-car!", [](auto&& xs, auto&&) { return caar(xs) = cadr(xs); }); - define("set-cdr!", [](auto&& xs, auto&&) { return cdar(xs) = cadr(xs); }); + define("set-car!", [](auto&& xs, auto&&...) { return caar(xs) = cadr(xs); }); + define("set-cdr!", [](auto&& xs, auto&&...) { return cdar(xs) = cadr(xs); }); /* ------------------------------------------------------------------------- * @@ -458,10 +458,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caar", [](let const& xs, auto&&) { return caar(car(xs)); }); - define("cadr", [](let const& xs, auto&&) { return cadr(car(xs)); }); - define("cdar", [](let const& xs, auto&&) { return cdar(car(xs)); }); - define("cddr", [](let const& xs, auto&&) { return cddr(car(xs)); }); + define("caar", [](let const& xs, auto&&...) { return caar(car(xs)); }); + define("cadr", [](let const& xs, auto&&...) { return cadr(car(xs)); }); + define("cdar", [](let const& xs, auto&&...) { return cdar(car(xs)); }); + define("cddr", [](let const& xs, auto&&...) { return cddr(car(xs)); }); /* ------------------------------------------------------------------------- * @@ -471,7 +471,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("null?", [](let const& xs, auto&&) + define("null?", [](let const& xs, auto&&...) { return car(xs).is() ? t : f; }); @@ -496,7 +496,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol->string", [](let const& xs, auto&&) + define("symbol->string", [](let const& xs, auto&&...) { return make(car(xs).as()); }); @@ -511,7 +511,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->symbol", [](let const& xs, auto&&) + define("string->symbol", [](let const& xs, auto&&...) { return intern(car(xs).as()); }); @@ -543,7 +543,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char->integer", [](let const& xs, auto&&) + define("char->integer", [](let const& xs, auto&&...) { if (xs.is() and car(xs).is()) { @@ -555,7 +555,7 @@ namespace meevax } }); - define("integer->char", [](let const& xs, auto&&) + define("integer->char", [](let const& xs, auto&&...) { if (xs.is() and car(xs).is()) { @@ -588,7 +588,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-string", [](let const& xs, auto&&) + define("make-string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -611,7 +611,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-length", [](let const& xs, auto&&) + define("string-length", [](let const& xs, auto&&...) { return make(car(xs).as().size()); }); @@ -626,7 +626,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-ref", [](let const& xs, auto&&) + define("string-ref", [](let const& xs, auto&&...) { return make(car(xs).as().at(static_cast(cadr(xs).as()))); }); @@ -649,7 +649,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-set!", [](let const& xs, auto&&) + define("string-set!", [](let const& xs, auto&&...) { car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs).as(); return car(xs); @@ -691,7 +691,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define STRING_COMPARE(OPERATOR) \ - [](let const& xs, auto&&) \ + [](let const& xs, auto&&...) \ { \ for (let const& each : cdr(xs)) \ { \ @@ -725,7 +725,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-append", [](let const& xs, auto&&) + define("string-append", [](let const& xs, auto&&...) { string result; @@ -754,7 +754,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->list", [](let const& xs, auto&&) + define("string->list", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -772,7 +772,7 @@ namespace meevax } }); - define("list->string", [](let const& xs, auto&&) + define("list->string", [](let const& xs, auto&&...) { string s; @@ -795,7 +795,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-copy", [](let const& xs, auto&&) + define("string-copy", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -834,7 +834,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-vector", [](let const& xs, auto&&) + define("make-vector", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -858,7 +858,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector", [](let const& xs, auto&&) + define("vector", [](let const& xs, auto&&...) { return make(for_each_in, xs); }); @@ -871,7 +871,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-length", [](let const& xs, auto&&) + define("vector-length", [](let const& xs, auto&&...) { return make(car(xs).as().size()); }); @@ -885,7 +885,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-ref", [](let const& xs, auto&&) + define("vector-ref", [](let const& xs, auto&&...) { return car(xs).as().at(static_cast(cadr(xs).as())); }); @@ -899,7 +899,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-set!", [](let const& xs, auto&&) + define("vector-set!", [](let const& xs, auto&&...) { return car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs); }); @@ -919,7 +919,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->list", [](let const& xs, auto&&) + define("vector->list", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -937,7 +937,7 @@ namespace meevax } }); - define("list->vector", [](let const& xs, auto&&) + define("list->vector", [](let const& xs, auto&&...) { return make(for_each_in, car(xs)); }); @@ -964,7 +964,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->string", [](let const& xs, auto&&) + define("vector->string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1013,7 +1013,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-fill!", [](let const& xs, auto&&) + define("vector-fill!", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1063,7 +1063,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("default-exception-handler", [](let const& xs, auto&&) -> object + define("default-exception-handler", [](let const& xs, auto&&...) -> object { throw car(xs); }); @@ -1084,7 +1084,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-error", [](let const& xs, auto&&) + define("make-error", [](let const& xs, auto&&...) { return make(car(xs), cdr(xs)); }); @@ -1119,11 +1119,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "input-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); - define( "output-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); - define( "binary-port?", [](let const& , auto&&) { return f; }); - define("textual-port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); - define( "port?", [](let const& xs, auto&&) { return car(xs).is_also() ? t : f; }); + define( "input-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); + define( "output-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); + define( "binary-port?", [](let const& , auto&&...) { return f; }); + define("textual-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); + define( "port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); /* ------------------------------------------------------------------------- * @@ -1135,7 +1135,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("input-port-open?", [](let const& xs, auto&&) + define("input-port-open?", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { @@ -1147,7 +1147,7 @@ namespace meevax } }); - define("output-port-open?", [](let const& xs, auto&&) + define("output-port-open?", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { @@ -1188,7 +1188,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-file", [](let const& xs, auto&&) + define("open-input-file", [](let const& xs, auto&&...) { return make(car(xs).as()); }); @@ -1206,7 +1206,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-file", [](let const& xs, auto&&) + define("open-output-file", [](let const& xs, auto&&...) { return make(car(xs).as()); }); @@ -1228,7 +1228,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("close-input-port", [](let const& xs, auto&&) + define("close-input-port", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { @@ -1238,7 +1238,7 @@ namespace meevax return unspecified_object; }); - define("close-output-port", [](let const& xs, auto&&) + define("close-output-port", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { @@ -1258,7 +1258,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-string", [](let const& xs, auto&&) + define("open-input-string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1282,7 +1282,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-string", [](let const& xs, auto&&) + define("open-output-string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1309,7 +1309,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("get-output-string", [](let const& xs, auto&&) + define("get-output-string", [](let const& xs, auto&&...) { return make(car(xs).as().str()); }); @@ -1325,7 +1325,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-char", [](let const& xs, auto&&) + define("%read-char", [](let const& xs, auto&&...) { try { @@ -1360,7 +1360,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%peek-char", [](let const& xs, auto&&) + define("%peek-char", [](let const& xs, auto&&...) { try { @@ -1425,7 +1425,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%char-ready?", [](let const& xs, auto&&) + define("%char-ready?", [](let const& xs, auto&&...) { return car(xs).as() ? t : f; }); @@ -1442,7 +1442,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-string", [](let const& xs, auto&&) + define("%read-string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1465,7 +1465,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("put-char", [](let const& xs, auto&&) + define("put-char", [](let const& xs, auto&&...) { cadr(xs).as() << static_cast(car(xs).as()); return unspecified_object; @@ -1483,7 +1483,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("put-string", [](let const& xs, auto&&) + define("put-string", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1511,7 +1511,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%flush-output-port", [](let const& xs, auto&&) + define("%flush-output-port", [](let const& xs, auto&&...) { car(xs).as() << std::flush; return unspecified_object; @@ -1550,7 +1550,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("digit-value", [](let const& xs, auto&&) + define("digit-value", [](let const& xs, auto&&...) { if (auto c = car(xs).as(); std::isdigit(c.codepoint)) { @@ -1605,31 +1605,31 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caaar", [](let const& xs, auto&&) { return caaar(car(xs)); }); - define("caadr", [](let const& xs, auto&&) { return caadr(car(xs)); }); - define("cadar", [](let const& xs, auto&&) { return cadar(car(xs)); }); - define("caddr", [](let const& xs, auto&&) { return caddr(car(xs)); }); - define("cdaar", [](let const& xs, auto&&) { return cdaar(car(xs)); }); - define("cdadr", [](let const& xs, auto&&) { return cdadr(car(xs)); }); - define("cddar", [](let const& xs, auto&&) { return cddar(car(xs)); }); - define("cdddr", [](let const& xs, auto&&) { return cdddr(car(xs)); }); - - define("caaaar", [](let const& xs, auto&&) { return caaaar(car(xs)); }); - define("caaadr", [](let const& xs, auto&&) { return caaadr(car(xs)); }); - define("caadar", [](let const& xs, auto&&) { return caadar(car(xs)); }); - define("caaddr", [](let const& xs, auto&&) { return caaddr(car(xs)); }); - define("cadaar", [](let const& xs, auto&&) { return cadaar(car(xs)); }); - define("cadadr", [](let const& xs, auto&&) { return cadadr(car(xs)); }); - define("caddar", [](let const& xs, auto&&) { return caddar(car(xs)); }); - define("cadddr", [](let const& xs, auto&&) { return cadddr(car(xs)); }); - define("cdaaar", [](let const& xs, auto&&) { return cdaaar(car(xs)); }); - define("cdaadr", [](let const& xs, auto&&) { return cdaadr(car(xs)); }); - define("cdadar", [](let const& xs, auto&&) { return cdadar(car(xs)); }); - define("cdaddr", [](let const& xs, auto&&) { return cdaddr(car(xs)); }); - define("cddaar", [](let const& xs, auto&&) { return cddaar(car(xs)); }); - define("cddadr", [](let const& xs, auto&&) { return cddadr(car(xs)); }); - define("cdddar", [](let const& xs, auto&&) { return cdddar(car(xs)); }); - define("cddddr", [](let const& xs, auto&&) { return cddddr(car(xs)); }); + define("caaar", [](let const& xs, auto&&...) { return caaar(car(xs)); }); + define("caadr", [](let const& xs, auto&&...) { return caadr(car(xs)); }); + define("cadar", [](let const& xs, auto&&...) { return cadar(car(xs)); }); + define("caddr", [](let const& xs, auto&&...) { return caddr(car(xs)); }); + define("cdaar", [](let const& xs, auto&&...) { return cdaar(car(xs)); }); + define("cdadr", [](let const& xs, auto&&...) { return cdadr(car(xs)); }); + define("cddar", [](let const& xs, auto&&...) { return cddar(car(xs)); }); + define("cdddr", [](let const& xs, auto&&...) { return cdddr(car(xs)); }); + + define("caaaar", [](let const& xs, auto&&...) { return caaaar(car(xs)); }); + define("caaadr", [](let const& xs, auto&&...) { return caaadr(car(xs)); }); + define("caadar", [](let const& xs, auto&&...) { return caadar(car(xs)); }); + define("caaddr", [](let const& xs, auto&&...) { return caaddr(car(xs)); }); + define("cadaar", [](let const& xs, auto&&...) { return cadaar(car(xs)); }); + define("cadadr", [](let const& xs, auto&&...) { return cadadr(car(xs)); }); + define("caddar", [](let const& xs, auto&&...) { return caddar(car(xs)); }); + define("cadddr", [](let const& xs, auto&&...) { return cadddr(car(xs)); }); + define("cdaaar", [](let const& xs, auto&&...) { return cdaaar(car(xs)); }); + define("cdaadr", [](let const& xs, auto&&...) { return cdaadr(car(xs)); }); + define("cdadar", [](let const& xs, auto&&...) { return cdadar(car(xs)); }); + define("cdaddr", [](let const& xs, auto&&...) { return cdaddr(car(xs)); }); + define("cddaar", [](let const& xs, auto&&...) { return cddaar(car(xs)); }); + define("cddadr", [](let const& xs, auto&&...) { return cddadr(car(xs)); }); + define("cdddar", [](let const& xs, auto&&...) { return cdddar(car(xs)); }); + define("cddddr", [](let const& xs, auto&&...) { return cddddr(car(xs)); }); } template <> @@ -1647,7 +1647,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eval", [](let const& xs, auto&&) + define("eval", [](let const& xs, auto&&...) { return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! }); @@ -1666,7 +1666,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("finite?", [](let const& xs, auto&&) + define("finite?", [](let const& xs, auto&&...) { return car(xs).as().is_finite() ? t : f; }); @@ -1681,7 +1681,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("infinite?", [](let const& xs, auto&&) + define("infinite?", [](let const& xs, auto&&...) { return car(xs).as().is_infinite() ? t : f; }); @@ -1696,15 +1696,15 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("nan?", [](let const& xs, auto&&) + define("nan?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_nan() ? t : f; }); - define("exp", [](let const& xs, auto&&) { return car(xs).as().exp(); }); - define("sqrt", [](let const& xs, auto&&) { return car(xs).as().sqrt(); }); + define("exp", [](let const& xs, auto&&...) { return car(xs).as().exp(); }); + define("sqrt", [](let const& xs, auto&&...) { return car(xs).as().sqrt(); }); - define("log", [](let const& xs, auto&&) + define("log", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1719,19 +1719,19 @@ namespace meevax } }); - define("sin", [](let const& xs, auto&&) { return car(xs).as().sin(); }); - define("cos", [](let const& xs, auto&&) { return car(xs).as().cos(); }); - define("tan", [](let const& xs, auto&&) { return car(xs).as().tan(); }); - define("asin", [](let const& xs, auto&&) { return car(xs).as().asin(); }); - define("acos", [](let const& xs, auto&&) { return car(xs).as().acos(); }); - define("sinh", [](let const& xs, auto&&) { return car(xs).as().sinh(); }); - define("cosh", [](let const& xs, auto&&) { return car(xs).as().cosh(); }); - define("tanh", [](let const& xs, auto&&) { return car(xs).as().tanh(); }); - define("asinh", [](let const& xs, auto&&) { return car(xs).as().asinh(); }); - define("acosh", [](let const& xs, auto&&) { return car(xs).as().acosh(); }); - define("atanh", [](let const& xs, auto&&) { return car(xs).as().atanh(); }); + define("sin", [](let const& xs, auto&&...) { return car(xs).as().sin(); }); + define("cos", [](let const& xs, auto&&...) { return car(xs).as().cos(); }); + define("tan", [](let const& xs, auto&&...) { return car(xs).as().tan(); }); + define("asin", [](let const& xs, auto&&...) { return car(xs).as().asin(); }); + define("acos", [](let const& xs, auto&&...) { return car(xs).as().acos(); }); + define("sinh", [](let const& xs, auto&&...) { return car(xs).as().sinh(); }); + define("cosh", [](let const& xs, auto&&...) { return car(xs).as().cosh(); }); + define("tanh", [](let const& xs, auto&&...) { return car(xs).as().tanh(); }); + define("asinh", [](let const& xs, auto&&...) { return car(xs).as().asinh(); }); + define("acosh", [](let const& xs, auto&&...) { return car(xs).as().acosh(); }); + define("atanh", [](let const& xs, auto&&...) { return car(xs).as().atanh(); }); - define("atan", [](let const& xs, auto&&) + define("atan", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -1773,7 +1773,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("load", [this](let const& xs, auto&&) + define("load", [this](let const& xs, auto&&...) { return load(car(xs).as()); }); @@ -1796,7 +1796,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("emergency-exit", [](let const& xs, auto&&) -> object + define("emergency-exit", [](let const& xs, auto&&...) -> object { switch (length(xs)) { @@ -1848,7 +1848,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read", [this](let const& xs, auto&&) + define("%read", [this](let const& xs, auto&&...) { try { @@ -1889,7 +1889,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%write-simple", [this](let const& xs, auto&&) + define("%write-simple", [this](let const& xs, auto&&...) { write(cadr(xs), car(xs)); return unspecified_object; @@ -1899,20 +1899,22 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { - define("%er-macro-transformer", [](let const& xs, auto & current_environment) + define("%er-macro-transformer", [](let const& xs, let const&, environment & current_environment) { return make(car(xs), current_environment); }); - define("er-macro-transformer?", [](let const& xs, auto&&) + define("er-macro-transformer?", [](let const& xs, auto&&...) { return car(xs).is() ? t : f; }); - define("identifier", [](let const& xs, auto & environment) + define("identifier", [](let const& xs, + let const& current_syntactic_environment, + auto & environment) { assert(car(xs).is()); - return environment.rename(car(xs), environment.syntactic_environment()); + return environment.rename(car(xs), current_syntactic_environment); }); /* ------------------------------------------------------------------------- @@ -1930,7 +1932,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier?", [](let const& xs, auto&&) + define("identifier?", [](let const& xs, auto&&...) { return is_identifier(car(xs)) ? t : f; }); @@ -1969,9 +1971,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("free-identifier=?", [](let const& xs, environment & currently) + define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) { - return currently.is_same_free_identifier(car(xs), cadr(xs)) ? t : f; + return current_environment.is_same_free_identifier(car(xs), cadr(xs)) ? t : f; }); /* ------------------------------------------------------------------------- @@ -1989,9 +1991,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("bound-identifier=?", [](let const& xs, environment & currently) + define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) { - return currently.is_same_bound_identifier(car(xs), cadr(xs)) ? t : f; + return current_environment.is_same_bound_identifier(car(xs), cadr(xs)) ? t : f; }); /* ------------------------------------------------------------------------- @@ -2005,7 +2007,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier->symbol", [](let const& xs, auto&&) + define("identifier->symbol", [](let const& xs, auto&&...) { switch (length(xs)) { @@ -2047,15 +2049,15 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("generate-identifier", [](let const& xs, environment & current) + define("generate-identifier", [](let const& xs, let const&, auto && current_environment) { switch (length(xs)) { case 0: - return current.generate_free_identifier(make()); + return current_environment.generate_free_identifier(make()); case 1: - return current.generate_free_identifier(car(xs)); + return current_environment.generate_free_identifier(car(xs)); default: throw invalid_application(intern("generate-identifier") | xs); @@ -2066,7 +2068,7 @@ namespace meevax define("r6rs:identifier?", is()); - define("macroexpand-1", [this](let const& xs, auto&&) + define("macroexpand-1", [this](let const& xs, auto&&...) { if (let const& macro = (*this)[caar(xs)]; macro.is()) { @@ -2078,7 +2080,7 @@ namespace meevax } }); - define("disassemble", [](let const& xs, auto&&) + define("disassemble", [](let const& xs, auto&&...) { if (0 < length(xs)) { @@ -2096,7 +2098,7 @@ namespace meevax return std::numeric_limits::is_iec559 ? t : f; }); - define("print", [](let const& xs, auto&&) + define("print", [](let const& xs, auto&&...) { for (let const& x : xs) { @@ -2121,12 +2123,12 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("foreign-function", [](let const& xs, auto&&) + define("foreign-function", [](let const& xs, auto&&...) { return make(cadr(xs).as(), car(xs).as()); }); - define("type-of", [](let const& xs, auto&&) + define("type-of", [](let const& xs, auto&&...) { std::cout << car(xs).type().name() << std::endl; diff --git a/test/vector.cpp b/test/vector.cpp index f0f589baa..1a0d2de67 100644 --- a/test/vector.cpp +++ b/test/vector.cpp @@ -173,7 +173,7 @@ auto main() -> int { auto module = environment(); - module.define("vector", [](let const& xs, auto&&) + module.define("vector", [](let const& xs, auto&&...) { return make(for_each_in, xs); }); From 2611c1545d4d57c81bec6c2409fba7c08ea5ce0f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 00:12:52 +0900 Subject: [PATCH 070/118] Rename member function `procedure::apply` to `call` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 4 ++-- include/meevax/kernel/procedure.hpp | 2 +- src/kernel/procedure.cpp | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b979e2b96..8879ed24a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.895.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.896.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.895_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.896_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.895 +Meevax Lisp System, version 0.3.896 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7b859c747..9c7389c95 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.895 +0.3.896 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index eb9c49fac..c105a5e67 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -528,7 +528,7 @@ inline namespace kernel * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), cadr(c), static_cast(*this)), cddr(s)); + s = cons(callee.as().call(cadr(s), cadr(c), static_cast(*this)), cddr(s)); c = cddr(c); } else if (callee.is()) /* --------------------------------- @@ -571,7 +571,7 @@ inline namespace kernel * * ------------------------------------------------------------------- */ { - s = cons(callee.as().apply(cadr(s), cadr(c), static_cast(*this)), cddr(s)); + s = cons(callee.as().call(cadr(s), cadr(c), static_cast(*this)), cddr(s)); c = cddr(c); } else if (callee.is()) /* --------------------------------- diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index 37b5eb954..19eaf0863 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -34,7 +34,7 @@ inline namespace kernel using applicable = std::function; - applicable apply; + applicable call; explicit procedure(std::string const&, applicable const&); diff --git a/src/kernel/procedure.cpp b/src/kernel/procedure.cpp index 7821b9c67..eb3d28bc5 100644 --- a/src/kernel/procedure.cpp +++ b/src/kernel/procedure.cpp @@ -29,12 +29,12 @@ inline namespace kernel { procedure::procedure(std::string const& name, applicable const& applicable) : description { name } - , apply { applicable } + , call { applicable } {} procedure::procedure(std::string const& name, std::string const& libfoo_so) : description { name } - , apply { dlsym(name, dlopen(libfoo_so)) } + , call { dlsym(name, dlopen(libfoo_so)) } {} auto procedure::dlopen(std::string const& libfoo_so) -> void * From cca1737645e5fbf9d2d12e6d61048dc816b302d7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 00:30:40 +0900 Subject: [PATCH 071/118] Rename struct `procedure`'s member typenames Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 2 +- include/meevax/kernel/procedure.hpp | 10 +++++----- src/kernel/procedure.cpp | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 8879ed24a..93f2031fd 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.896.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.897.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.896_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.897_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.896 +Meevax Lisp System, version 0.3.897 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9c7389c95..b71481db7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.896 +0.3.897 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index 41665e9f5..fbbcf5aa4 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -39,7 +39,7 @@ inline namespace kernel IMPORT(environment, read, NIL); template - using dispatcher = std::unordered_map; + using dispatcher = std::unordered_map; const dispatcher short_options, short_options_with_arguments; diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index 19eaf0863..8e66fee53 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -30,19 +30,19 @@ inline namespace kernel struct procedure : public description { - using signature = PROCEDURE((*)); + using function_pointer_type = PROCEDURE((*)); - using applicable = std::function; + using function_type = std::function; - applicable call; + function_type call; - explicit procedure(std::string const&, applicable const&); + explicit procedure(std::string const&, function_type const&); explicit procedure(std::string const&, std::string const&); static auto dlopen(std::string const&) -> void *; - static auto dlsym(std::string const&, void * const) -> signature; + static auto dlsym(std::string const&, void * const) -> function_pointer_type; }; auto operator <<(std::ostream &, procedure const&) -> std::ostream &; diff --git a/src/kernel/procedure.cpp b/src/kernel/procedure.cpp index eb3d28bc5..f2df44b0c 100644 --- a/src/kernel/procedure.cpp +++ b/src/kernel/procedure.cpp @@ -27,9 +27,9 @@ namespace meevax { inline namespace kernel { - procedure::procedure(std::string const& name, applicable const& applicable) + procedure::procedure(std::string const& name, function_type const& call) : description { name } - , call { applicable } + , call { call } {} procedure::procedure(std::string const& name, std::string const& libfoo_so) @@ -75,11 +75,11 @@ inline namespace kernel } } - auto procedure::dlsym(std::string const& name, void * const handle) -> signature + auto procedure::dlsym(std::string const& name, void * const handle) -> function_pointer_type { if (auto address = ::dlsym(handle, name.c_str()); address) { - return reinterpret_cast(address); + return reinterpret_cast(address); } else { From 4257f01192f7d72679fe621975c11bb0133baeb7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 00:46:09 +0900 Subject: [PATCH 072/118] Rename struct `is` to `type_predicate` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/procedure.hpp | 12 +++------ src/library/meevax.cpp | 40 ++++++++++++++--------------- 4 files changed, 28 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 93f2031fd..6501fffce 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.897.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.898.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.897_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.898_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.897 +Meevax Lisp System, version 0.3.898 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b71481db7..8c01402d7 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.897 +0.3.898 diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index 8e66fee53..e3fd8af8e 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -48,16 +48,12 @@ inline namespace kernel auto operator <<(std::ostream &, procedure const&) -> std::ostream &; template - struct is + struct type_predicate { - auto operator ()(const_reference xs, const_reference, environment const&) const -> const_reference + template + auto operator ()(const_reference xs, Ts&&...) const -> const_reference { - auto is_T = [](const_reference x) - { - return x.is(); - }; - - return std::all_of(std::begin(xs), std::end(xs), is_T) ? t : f; + return car(xs).is() ? t : f; } }; } // namespace kernel diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 888caf066..d2271c4f8 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -106,10 +106,10 @@ namespace meevax define("rational?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); define("integer?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); - define("%complex?", is()); - define("ratio?", is()); - define("single-float?", is()); - define("double-float?", is()); + define("%complex?", type_predicate()); + define("ratio?", type_predicate()); + define("single-float?", type_predicate()); + define("double-float?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -119,7 +119,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("exact-integer?", is()); + define("exact-integer?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -393,7 +393,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("pair?", is()); + define("pair?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -484,7 +484,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol?", is()); + define("symbol?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -524,7 +524,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char?", is()); + define("char?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -575,7 +575,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string?", is()); + define("string?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -821,7 +821,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector?", is()); + define("vector?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -1044,11 +1044,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("closure?", is()); + define("closure?", type_predicate()); - define("continuation?", is()); + define("continuation?", type_predicate()); - define("foreign-function?", is()); + define("foreign-function?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -1100,10 +1100,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "error?", is< error>()); - define( "read-error?", is< read_error>()); - define( "file-error?", is< file_error>()); - define("syntax-error?", is()); + define( "error?", type_predicate< error>()); + define( "read-error?", type_predicate< read_error>()); + define( "file-error?", type_predicate< file_error>()); + define("syntax-error?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -1390,7 +1390,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eof-object?", is()); + define("eof-object?", type_predicate()); /* ------------------------------------------------------------------------- * @@ -2064,9 +2064,9 @@ namespace meevax } }); - define("transformer?", is()); + define("transformer?", type_predicate()); - define("r6rs:identifier?", is()); + define("r6rs:identifier?", type_predicate()); define("macroexpand-1", [this](let const& xs, auto&&...) { From e723ce15fbea009913fd30aa107a8c82275e90f3 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 01:13:53 +0900 Subject: [PATCH 073/118] Rename experimental procedure `r6rs:identifier?` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 2 +- src/library/meevax.cpp | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6501fffce..31a42f2be 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.898.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.899.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.898_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.899_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.898 +Meevax Lisp System, version 0.3.899 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 8c01402d7..77b4dbddd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.898 +0.3.899 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index c105a5e67..5ddc4870a 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -417,7 +417,7 @@ inline namespace kernel * s e (%join) (c . d) => s e c d * * ------------------------------------------------------------------- */ - assert(cdr(c).is()); + assert(cdr(c).template is()); c = car(d); d = cdr(d); goto decode; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index d2271c4f8..84da1d34c 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2066,8 +2066,6 @@ namespace meevax define("transformer?", type_predicate()); - define("r6rs:identifier?", type_predicate()); - define("macroexpand-1", [this](let const& xs, auto&&...) { if (let const& macro = (*this)[caar(xs)]; macro.is()) From 427b0633faa359469a40368ad912d63137a593a9 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 01:38:22 +0900 Subject: [PATCH 074/118] Update procedure `macroexpand-1` to not to capture `this` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- src/library/meevax.cpp | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 31a42f2be..5b6283d38 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.899.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.900.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.899_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.900_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.899 +Meevax Lisp System, version 0.3.900 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 77b4dbddd..90ac6bbed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.899 +0.3.900 diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 84da1d34c..0265697b2 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2066,11 +2066,11 @@ namespace meevax define("transformer?", type_predicate()); - define("macroexpand-1", [this](let const& xs, auto&&...) + define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) { - if (let const& macro = (*this)[caar(xs)]; macro.is()) + if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is()) { - return macro.as().expand(cons(macro, car(xs))); + return macro.as().expand(cons(macro, cdar(xs))); } else { From 4150ab62c0e5282c558f78af571d4b5f275f8302 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 03:06:52 +0900 Subject: [PATCH 075/118] Simplify free function `disassemble` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- src/kernel/instruction.cpp | 13 +++---------- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 5b6283d38..154e19840 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.900.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.901.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.900_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.901_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.900 +Meevax Lisp System, version 0.3.901 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 90ac6bbed..840ef0160 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.900 +0.3.901 diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 431731613..d66bf5ef4 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -90,13 +90,9 @@ inline namespace kernel case mnemonic::dummy: case mnemonic::join: case mnemonic::letrec: - os << *iter << "\n"; - ++offset; - break; - case mnemonic::return_: case mnemonic::stop: - os << *iter << magenta(")\n"); + os << *iter << "\n"; ++offset; break; @@ -121,20 +117,17 @@ inline namespace kernel case mnemonic::load_closure: case mnemonic::load_continuation: os << *iter << "\n"; - disassemble(os, *++iter, depth + 1); ++offset; + disassemble(os, *++iter, depth + 1); break; case mnemonic::select: case mnemonic::tail_select: os << *iter << "\n"; + ++offset; disassemble(os, *++iter, depth + 1); disassemble(os, *++iter, depth + 1); - ++offset; break; - - default: - assert(false); } } } From 1fa84ac478bdd3ef51dfb41d65c3f2fd1e69b0b5 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 10:01:09 +0900 Subject: [PATCH 076/118] Rename struct `transformer` to `hygienic_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 33 ++++++++----------------------- src/library/meevax.cpp | 8 ++++---- 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 154e19840..b9bac04dd 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.901.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.903.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.901_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.903_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.901 +Meevax Lisp System, version 0.3.903 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 840ef0160..eebbfb53d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.901 +0.3.903 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 5ddc4870a..58d9e7562 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -48,13 +48,13 @@ inline namespace kernel c, // code (instructions yet to be executed) d; // dump (s e c . d) - struct transformer + struct hygienic_macro_transformer { let spec; environment expander; - explicit transformer(environment const& current_environment) + explicit hygienic_macro_transformer(environment const& current_environment) : expander { current_environment } { expander.c = compile(context::outermost, @@ -112,7 +112,7 @@ inline namespace kernel return expander.apply(spec, form); } - friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & + friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & { return os << magenta("#,(") << green("fork/csc ") << faint("#;", &datum) << magenta(")"); } @@ -222,11 +222,11 @@ inline namespace kernel } else if (let const& notation = std::as_const(current_environment).notate(car(current_expression), current_syntactic_environment); notation.is()) { - assert(notation.as().strip().is()); + assert(notation.as().strip().is()); return compile(context::none, current_environment, - notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), + notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), current_syntactic_environment, current_continuation); } @@ -238,11 +238,11 @@ inline namespace kernel current_syntactic_environment, current_continuation); } - else if (applicant.is()) + else if (applicant.is()) { return compile(context::none, current_environment, - applicant.as().expand(cons(applicant, cdr(current_expression))), + applicant.as().expand(cons(applicant, cdr(current_expression))), current_syntactic_environment, current_continuation); } @@ -387,7 +387,7 @@ inline namespace kernel * s e (%fork c1 . c2) d => ( . s) e c2 d * * ------------------------------------------------------------------- */ - s = cons(make(static_cast(*this)), s); + s = cons(make(static_cast(*this)), s); c = cddr(c); goto decode; @@ -441,30 +441,13 @@ inline namespace kernel * ------------------------------------------------------------------- */ [&]() { - // PRINT(cadr(c).template is()); - - // let const& expression = cadr(c).template as().expression(); - // PRINT(expression); - let const& syntactic_environment = cadr(c).template as().syntactic_environment(); - // PRINT(syntactic_environment); - - // PRINT(car(syntactic_environment)); - // PRINT(cdr(syntactic_environment)); for (let const& keyword_ : car(syntactic_environment)) { - // PRINT(keyword_); - // PRINT(keyword_.is()); - let & binding = keyword_.as().strip(); binding = environment(static_cast(*this)).execute(binding); - - // PRINT(binding.is()); - // PRINT(binding.as().spec); - // PRINT(binding.as().spec.template as().c()); - // PRINT(binding.as().spec.template as().e()); } }(); diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 0265697b2..14b0a6bdf 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1649,7 +1649,7 @@ namespace meevax define("eval", [](let const& xs, auto&&...) { - return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! + return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! }); } @@ -2064,13 +2064,13 @@ namespace meevax } }); - define("transformer?", type_predicate()); + define("transformer?", type_predicate()); define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) { - if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is()) + if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is()) { - return macro.as().expand(cons(macro, cdar(xs))); + return macro.as().expand(cons(macro, cdar(xs))); } else { From 65621c3de69ee046d1e47d845049d888db38ec5a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 10:12:46 +0900 Subject: [PATCH 077/118] Rename struct `syntax`'s member types --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 10 +++++----- include/meevax/kernel/syntax.hpp | 8 ++++---- src/kernel/syntax.cpp | 4 ++-- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b9bac04dd..567fb171f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.903.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.904.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.903_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.904_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.903 +Meevax Lisp System, version 0.3.904 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index eebbfb53d..18b67e999 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.903 +0.3.904 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 58d9e7562..e71eecb0b 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -232,11 +232,11 @@ inline namespace kernel } else if (let const& applicant = notation.is() ? notation.as().strip() : car(current_expression); applicant.is_also()) { - return applicant.as().transform(current_context, - current_environment, - cdr(current_expression), - current_syntactic_environment, - current_continuation); + return applicant.as().compile(current_context, + current_environment, + cdr(current_expression), + current_syntactic_environment, + current_continuation); } else if (applicant.is()) { diff --git a/include/meevax/kernel/syntax.hpp b/include/meevax/kernel/syntax.hpp index a7f1402fe..28cc51054 100644 --- a/include/meevax/kernel/syntax.hpp +++ b/include/meevax/kernel/syntax.hpp @@ -35,13 +35,13 @@ inline namespace kernel { struct syntax : public description { - using signature = SYNTAX((*)); + using function_pointer_type = SYNTAX((*)); - using transformer = std::function; + using function_type = std::function; - transformer transform; + function_type compile; - explicit syntax(std::string const&, transformer const&); + explicit syntax(std::string const&, function_type const&); }; auto operator <<(std::ostream &, syntax const&) -> std::ostream &; diff --git a/src/kernel/syntax.cpp b/src/kernel/syntax.cpp index 9121c2171..2c3e9464b 100644 --- a/src/kernel/syntax.cpp +++ b/src/kernel/syntax.cpp @@ -20,9 +20,9 @@ namespace meevax { inline namespace kernel { - syntax::syntax(std::string const& name, transformer const& transform) + syntax::syntax(std::string const& name, function_type const& compile) : description { name } - , transform { transform } + , compile { compile } {} auto operator <<(std::ostream & os, syntax const& datum) -> std::ostream & From 7633bce9edbcce42b60b751d872f3b0ad77e48a7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 11:43:13 +0900 Subject: [PATCH 078/118] Add new procedure-based type `predicate` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/machine.hpp | 19 ++-- include/meevax/kernel/procedure.hpp | 12 +-- src/library/meevax.cpp | 155 +++++++++++++++++----------- 5 files changed, 114 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index 567fb171f..8f9f2aeee 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.904.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.905.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.904_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.905_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.904 +Meevax Lisp System, version 0.3.905 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 18b67e999..0231247ec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.904 +0.3.905 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index e71eecb0b..064b1d761 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -48,9 +48,12 @@ inline namespace kernel c, // code (instructions yet to be executed) d; // dump (s e c . d) - struct hygienic_macro_transformer + struct macro_transformer + {}; + + struct hygienic_macro_transformer : public macro_transformer { - let spec; + let transform; environment expander; @@ -62,7 +65,7 @@ inline namespace kernel cadr(expander.c).template as().expression(), cadr(expander.c).template as().syntactic_environment()); - spec = expander.execute(); + transform = expander.execute(); expander.reset(); } @@ -98,7 +101,7 @@ inline namespace kernel * * --------------------------------------------------------------------- */ { - assert(spec.template is()); + assert(transform.template is()); assert(expander.d.template is()); assert(expander.c.template is()); @@ -109,7 +112,7 @@ inline namespace kernel assert(car(expander.c).template as().value == mnemonic::stop); assert(cdr(expander.c).template is()); - return expander.apply(spec, form); + return expander.apply(transform, form); } friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & @@ -118,7 +121,7 @@ inline namespace kernel } }; - struct er_macro_transformer // explicit-renaming + struct er_macro_transformer : public macro_transformer { let const transform; @@ -141,9 +144,9 @@ inline namespace kernel return expander.evaluate(car(xs)); }); - auto compare = make("compare", [](let const& xs, let const&, environment &) + auto compare = make("compare", [](let const& xs, let const&, environment &) { - return eqv(car(xs), cadr(xs)) ? t : f; + return eqv(car(xs), cadr(xs)); }); return expander.apply(transform, list(form, rename, compare)); diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index e3fd8af8e..d70f77718 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -47,14 +47,12 @@ inline namespace kernel auto operator <<(std::ostream &, procedure const&) -> std::ostream &; - template - struct type_predicate + struct predicate : public procedure { - template - auto operator ()(const_reference xs, Ts&&...) const -> const_reference - { - return car(xs).is() ? t : f; - } + template + explicit predicate(std::string const& name, Callable && call) + : procedure { name, [call](auto&&... xs) { return call(std::forward(xs)...) ? t : f; } } + {} }; } // namespace kernel } // namespace meevax diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 14b0a6bdf..4c647f742 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -49,9 +49,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eqv?", [](let const& xs, auto&&...) // TODO Rename to value=? + define("eqv?", [](let const& xs, auto&&...) // TODO Rename to value=? { - return eqv(car(xs), cadr(xs)) ? t : f; + return eqv(car(xs), cadr(xs)); }); /* ------------------------------------------------------------------------- @@ -73,9 +73,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eq?", [](auto&& xs, auto&&...) // TODO Rename to reference=? + define("eq?", [](auto&& xs, auto&&...) // TODO Rename to reference=? { - return eq(car(xs), cadr(xs)) ? t : f; + return eq(car(xs), cadr(xs)); }); /* ------------------------------------------------------------------------- @@ -100,16 +100,16 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); - define("complex?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_complex () ? t : f; }); - define("real?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_real () ? t : f; }); - define("rational?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_rational() ? t : f; }); - define("integer?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_integer () ? t : f; }); + define("number?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); + define("complex?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_complex (); }); + define("real?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_real (); }); + define("rational?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_rational(); }); + define("integer?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_integer (); }); - define("%complex?", type_predicate()); - define("ratio?", type_predicate()); - define("single-float?", type_predicate()); - define("double-float?", type_predicate()); + define("%complex?", [](let const& xs, auto&&...) { return car(xs).is(); }); + define("ratio?", [](let const& xs, auto&&...) { return car(xs).is(); }); + define("single-float?", [](let const& xs, auto&&...) { return car(xs).is(); }); + define("double-float?", [](let const& xs, auto&&...) { return car(xs).is(); }); /* ------------------------------------------------------------------------- * @@ -119,7 +119,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("exact-integer?", type_predicate()); + define("exact-integer?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -157,13 +160,13 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, COMPARE) \ - define(#SYMBOL, [](let const& xs, auto&&...) \ + define(#SYMBOL, [](let const& xs, auto&&...) \ { \ return std::adjacent_find( \ std::begin(xs), std::end(xs), [](let const& a, let const& b) \ { \ return not COMPARE(a.as(), b); \ - }) == std::end(xs) ? t : f; \ + }) == std::end(xs); \ }) DEFINE(= , std::equal_to ()); @@ -393,7 +396,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("pair?", type_predicate()); + define("pair?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -471,9 +477,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("null?", [](let const& xs, auto&&...) + define("null?", [](let const& xs, auto&&...) { - return car(xs).is() ? t : f; + return car(xs).is(); }); /* ------------------------------------------------------------------------- @@ -484,7 +490,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol?", type_predicate()); + define("symbol?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -524,7 +533,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char?", type_predicate()); + define("char?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -575,7 +587,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string?", type_predicate()); + define("string?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -821,7 +836,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector?", type_predicate()); + define("vector?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -1044,11 +1062,20 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("closure?", type_predicate()); + define("closure?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); - define("continuation?", type_predicate()); + define("continuation?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); - define("foreign-function?", type_predicate()); + define("foreign-function?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -1100,10 +1127,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "error?", type_predicate< error>()); - define( "read-error?", type_predicate< read_error>()); - define( "file-error?", type_predicate< file_error>()); - define("syntax-error?", type_predicate()); + define( "error?", [](let const& xs, auto&&...) { return car(xs).is< error>(); }); + define( "read-error?", [](let const& xs, auto&&...) { return car(xs).is< read_error>(); }); + define( "file-error?", [](let const& xs, auto&&...) { return car(xs).is< file_error>(); }); + define("syntax-error?", [](let const& xs, auto&&...) { return car(xs).is(); }); /* ------------------------------------------------------------------------- * @@ -1119,11 +1146,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "input-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); - define( "output-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); - define( "binary-port?", [](let const& , auto&&...) { return f; }); - define("textual-port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); - define( "port?", [](let const& xs, auto&&...) { return car(xs).is_also() ? t : f; }); + define( "input-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); + define( "output-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); + define( "binary-port?", [](let const& , auto&&...) { return false; }); + define("textual-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); + define( "port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); /* ------------------------------------------------------------------------- * @@ -1135,27 +1162,27 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("input-port-open?", [](let const& xs, auto&&...) + define("input-port-open?", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { - return x.as().is_open() ? t : f; + return x.as().is_open(); } else { - return x.is_also() ? t : f; + return x.is_also(); } }); - define("output-port-open?", [](let const& xs, auto&&...) + define("output-port-open?", [](let const& xs, auto&&...) { if (let const& x = car(xs); x.is_also()) { - return x.as().is_open() ? t : f; + return x.as().is_open(); } else { - return x.is_also() ? t : f; + return x.is_also(); } }); @@ -1390,7 +1417,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eof-object?", type_predicate()); + define("eof-object?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); /* ------------------------------------------------------------------------- * @@ -1425,9 +1455,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%char-ready?", [](let const& xs, auto&&...) + define("%char-ready?", [](let const& xs, auto&&...) { - return car(xs).as() ? t : f; + return static_cast(car(xs).as()); }); /* ------------------------------------------------------------------------- @@ -1666,9 +1696,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("finite?", [](let const& xs, auto&&...) + define("finite?", [](let const& xs, auto&&...) { - return car(xs).as().is_finite() ? t : f; + return car(xs).as().is_finite(); }); /* ------------------------------------------------------------------------- @@ -1681,9 +1711,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("infinite?", [](let const& xs, auto&&...) + define("infinite?", [](let const& xs, auto&&...) { - return car(xs).as().is_infinite() ? t : f; + return car(xs).as().is_infinite(); }); /* ------------------------------------------------------------------------- @@ -1696,9 +1726,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("nan?", [](let const& xs, auto&&...) + define("nan?", [](let const& xs, auto&&...) { - return car(xs).is_also() and car(xs).as().is_nan() ? t : f; + return car(xs).is_also() and car(xs).as().is_nan(); }); define("exp", [](let const& xs, auto&&...) { return car(xs).as().exp(); }); @@ -1904,9 +1934,9 @@ namespace meevax return make(car(xs), current_environment); }); - define("er-macro-transformer?", [](let const& xs, auto&&...) + define("er-macro-transformer?", [](let const& xs, auto&&...) { - return car(xs).is() ? t : f; + return car(xs).is(); }); define("identifier", [](let const& xs, @@ -1932,9 +1962,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier?", [](let const& xs, auto&&...) + define("identifier?", [](let const& xs, auto&&...) { - return is_identifier(car(xs)) ? t : f; + return is_identifier(car(xs)); }); /* ------------------------------------------------------------------------- @@ -1971,9 +2001,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) + define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) { - return current_environment.is_same_free_identifier(car(xs), cadr(xs)) ? t : f; + return current_environment.is_same_free_identifier(car(xs), cadr(xs)); }); /* ------------------------------------------------------------------------- @@ -1991,9 +2021,9 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) + define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) { - return current_environment.is_same_bound_identifier(car(xs), cadr(xs)) ? t : f; + return current_environment.is_same_bound_identifier(car(xs), cadr(xs)); }); /* ------------------------------------------------------------------------- @@ -2064,7 +2094,10 @@ namespace meevax } }); - define("transformer?", type_predicate()); + define("transformer?", [](let const& xs, auto&&...) + { + return car(xs).is_also(); + }); define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) { @@ -2091,9 +2124,9 @@ namespace meevax return standard_output; }); - define("ieee-float?", [](auto&&...) + define("ieee-float?", [](auto&&...) { - return std::numeric_limits::is_iec559 ? t : f; + return std::numeric_limits::is_iec559; }); define("print", [](let const& xs, auto&&...) From 3abfa1d84c7fa8f502ff35477496686103a1e0b7 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 11:57:15 +0900 Subject: [PATCH 079/118] Update string comparisons with struct `predicate` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- src/library/meevax.cpp | 31 ++++++++++++------------------- 3 files changed, 16 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 8f9f2aeee..f05305c1d 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.905.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.906.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.905_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.906_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.905 +Meevax Lisp System, version 0.3.906 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 0231247ec..861a736d0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.905 +0.3.906 diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 4c647f742..d39acb131 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -705,29 +705,22 @@ namespace meevax * * ---------------------------------------------------------------------- */ - #define STRING_COMPARE(OPERATOR) \ + #define STRING_COMPARE(COMPARE) \ [](let const& xs, auto&&...) \ { \ - for (let const& each : cdr(xs)) \ - { \ - if (car(xs).as() OPERATOR each.as()) \ - { \ - continue; \ - } \ - else \ - { \ - return f; \ - } \ - } \ - \ - return t; \ + return std::adjacent_find( \ + std::begin(xs), std::end(xs), [](let const& a, let const& b) \ + { \ + return not COMPARE(a.as_const(), \ + b.as_const()); \ + }) == std::end(xs); \ } - define("string=?", STRING_COMPARE(==)); - define("string("string>?", STRING_COMPARE(> )); - define("string<=?", STRING_COMPARE(<=)); - define("string>=?", STRING_COMPARE(>=)); + define("string=?", STRING_COMPARE(std::equal_to ())); + define("string())); + define("string<=?", STRING_COMPARE(std::less_equal ())); + define("string>?", STRING_COMPARE(std::greater ())); + define("string>=?", STRING_COMPARE(std::greater_equal())); #undef STRING_COMPARE From 35695fd071560c503015a9c4b535d60b2bd32554 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 19:29:10 +0900 Subject: [PATCH 080/118] Add new transformer constructor `hygienic-macro-transformer` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- basis/overture.ss | 286 ++++++++++++++++-------------- basis/r7rs.ss | 28 +-- basis/srfi-39.ss | 12 +- basis/srfi-45.ss | 14 +- basis/srfi-78.ss | 18 +- basis/srfi-8.ss | 12 +- include/meevax/kernel/machine.hpp | 15 ++ src/library/meevax.cpp | 11 +- test/er-macro-transformer.ss | 10 +- test/r7rs.ss | 4 - 12 files changed, 228 insertions(+), 190 deletions(-) diff --git a/README.md b/README.md index f05305c1d..8c0467069 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.906.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.907.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.906_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.907_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.906 +Meevax Lisp System, version 0.3.907 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 861a736d0..7f70fcabf 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.906 +0.3.907 diff --git a/basis/overture.ss b/basis/overture.ss index e795ffb0d..44952eb90 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -9,10 +9,12 @@ (lambda (import . import-sets) (list quote (cons 'import import-sets))))) -(define-syntax (syntax datum) - (if (pair? datum) - (list fork/csc (list lambda '() datum)) - (eval datum (fork/csc identity)))) +(define-syntax syntax + (hygienic-macro-transformer + (lambda (syntax datum) + (if (pair? datum) + (list fork/csc (list lambda '() datum)) + (eval datum (fork/csc identity)))))) (define (current-environment-specifier) (fork/csc identity)) @@ -24,42 +26,48 @@ (define (unspecified) (if #f #f)) -(define-syntax (cond . clauses) - (if (null? clauses) - (unspecified) - ((lambda (clause) - (if (free-identifier=? else (car clause)) - (if (pair? (cdr clauses)) - (error "else clause must be at the end of cond clause" clauses) - (cons begin (cdr clause))) - (if (if (null? (cdr clause)) #t - (free-identifier=? => (cadr clause))) - (list (list lambda (list result) - (list if result - (if (null? (cdr clause)) result - (list (car (cddr clause)) result)) - (cons cond (cdr clauses)))) - (car clause)) - (list if (car clause) - (cons begin (cdr clause)) - (cons cond (cdr clauses)))))) - (car clauses)))) - -(define-syntax (and . tests) - (cond ((null? tests)) - ((null? (cdr tests)) (car tests)) - (else (list if (car tests) - (cons and (cdr tests)) - #f)))) - -(define-syntax (or . tests) - (cond ((null? tests) #f) - ((null? (cdr tests)) (car tests)) - (else (list (list lambda (list result) - (list if result - result - (cons or (cdr tests)))) - (car tests))))) +(define-syntax cond + (hygienic-macro-transformer + (lambda (cond . clauses) + (if (null? clauses) + (unspecified) + ((lambda (clause) + (if (free-identifier=? else (car clause)) + (if (pair? (cdr clauses)) + (error "else clause must be at the end of cond clause" clauses) + (cons begin (cdr clause))) + (if (if (null? (cdr clause)) #t + (free-identifier=? => (cadr clause))) + (list (list lambda (list result) + (list if result + (if (null? (cdr clause)) result + (list (car (cddr clause)) result)) + (cons cond (cdr clauses)))) + (car clause)) + (list if (car clause) + (cons begin (cdr clause)) + (cons cond (cdr clauses)))))) + (car clauses)))))) + +(define-syntax and + (hygienic-macro-transformer + (lambda (and . tests) + (cond ((null? tests)) + ((null? (cdr tests)) (car tests)) + (else (list if (car tests) + (cons and (cdr tests)) + #f)))))) + +(define-syntax or + (hygienic-macro-transformer + (lambda (or . tests) + (cond ((null? tests) #f) + ((null? (cdr tests)) (car tests)) + (else (list (list lambda (list result) + (list if result + result + (cons or (cdr tests)))) + (car tests))))))) (define (append-2 x y) (if (null? x) y @@ -83,53 +91,51 @@ (car xs))) (reverse xs)))) -(define-syntax (quasiquote template) - (define (expand x depth) - (cond - ((pair? x) - (cond - - ((free-identifier=? unquote (car x)) - (if (<= depth 0) - (cadr x) - (list list (list quote 'unquote) (expand (cadr x) (- depth 1))))) - - ((free-identifier=? unquote-splicing (car x)) - (if (<= depth 0) - (list cons (expand (car x) depth) - (expand (cdr x) depth)) - (list list (list quote 'unquote-splicing) - (expand (cadr x) (- depth 1))))) - - ((free-identifier=? quasiquote (car x)) - (list list (list quote 'quasiquote) - (expand (cadr x) (+ depth 1)))) - - ((and (<= depth 0) - (pair? (car x)) - (free-identifier=? unquote-splicing (caar x))) - (if (null? (cdr x)) - (cadr (car x)) - (list append (cadr (car x)) (expand (cdr x) depth)))) - - (else (list cons (expand (car x) depth) - (expand (cdr x) depth))))) - - ((vector? x) - (list list->vector (expand (vector->list x) depth))) - - ((or (identifier? x) - (null? x)) - (list quote x)) - - (else x))) - - (expand template 0)) +(define-syntax quasiquote + (hygienic-macro-transformer + (lambda (quasiquote template) + (define (expand x depth) + (cond ((pair? x) + (cond ((free-identifier=? unquote (car x)) + (if (<= depth 0) + (cadr x) + (list list (list quote 'unquote) (expand (cadr x) (- depth 1))))) + ((free-identifier=? unquote-splicing (car x)) + (if (<= depth 0) + (list cons (expand (car x) depth) + (expand (cdr x) depth)) + (list list (list quote 'unquote-splicing) + (expand (cadr x) (- depth 1))))) + ((free-identifier=? quasiquote (car x)) + (list list (list quote 'quasiquote) + (expand (cadr x) (+ depth 1)))) + ((and (<= depth 0) + (pair? (car x)) + (free-identifier=? unquote-splicing (caar x))) + (if (null? (cdr x)) + (cadr (car x)) + (list append (cadr (car x)) (expand (cdr x) depth)))) + (else (list cons (expand (car x) depth) + (expand (cdr x) depth))))) + ((vector? x) + (list list->vector (expand (vector->list x) depth))) + ((or (identifier? x) + (null? x)) + (list quote x)) + (else x))) + (expand template 0)))) (define (not x) (if x #f #t)) -(define-syntax (when test . body) `(,if ,test (,begin ,@body))) ; TODO MOVE INTO (scheme base) -(define-syntax (unless test . body) `(,if (,not ,test) (,begin ,@body))) ; TODO MOVE INTO (scheme base) +(define-syntax when + (hygienic-macro-transformer + (lambda (when test . body) + `(,if ,test (,begin ,@body))))) + +(define-syntax unless + (hygienic-macro-transformer + (lambda (unless test . body) + `(,if (,not ,test) (,begin ,@body))))) (define (map f x . xs) ; map-unorder (define (map-1 f x xs) @@ -193,20 +199,26 @@ #f) (any-2+ f (cons x xs)))) -(define-syntax (let bindings . body) - (if (identifier? bindings) - `(,letrec ((,bindings (,lambda ,(map car (car body)) ,@(cdr body)))) - (,bindings ,@(map cadr (car body)))) - `((,lambda ,(map car bindings) ,@body) ,@(map cadr bindings)))) - -(define-syntax (let* bindings . body) - (if (or (null? bindings) - (null? (cdr bindings))) - `(,let (,(car bindings)) ,@body) - `(,let (,(car bindings)) (,let* ,(cdr bindings) ,@body)))) - -(define-syntax (letrec* bindings . body) - `(,let () ,@(map (lambda (x) (cons define x)) bindings) ,@body)) +(define-syntax let + (hygienic-macro-transformer + (lambda (let bindings . body) + (if (identifier? bindings) + `(,letrec ((,bindings (,lambda ,(map car (car body)) ,@(cdr body)))) + (,bindings ,@(map cadr (car body)))) + `((,lambda ,(map car bindings) ,@body) ,@(map cadr bindings)))))) + +(define-syntax let* + (hygienic-macro-transformer + (lambda (let* bindings . body) + (if (or (null? bindings) + (null? (cdr bindings))) + `(,let (,(car bindings)) ,@body) + `(,let (,(car bindings)) (,let* ,(cdr bindings) ,@body)))))) + +(define-syntax letrec* + (hygienic-macro-transformer + (lambda (letrec* bindings . body) + `(,let () ,@(map (lambda (x) (cons define x)) bindings) ,@body)))) (define (member o x . c) ; for case (let ((compare (if (pair? c) (car c) equal?))) @@ -218,46 +230,44 @@ (define (memq o x) (member o x eq?)) (define (memv o x) (member o x eqv?)) -(define-syntax (case key . clauses) - (define (body expressions) - (cond - ((null? expressions) result) - ((free-identifier=? => (car expressions)) `(,(cadr expressions) ,result)) - (else `(,begin ,@expressions)))) - - (define (each-clause clauses) - (cond - ((null? clauses) (unspecified)) - ((free-identifier=? else (caar clauses)) - (body (cdar clauses))) - ((and (pair? (caar clauses)) - (null? (cdr (caar clauses)))) - `(,if (,eqv? ,result (,quote ,(car (caar clauses)))) - ,(body (cdar clauses)) - ,(each-clause (cdr clauses)))) - (else - `(,if (,memv ,result (,quote ,(caar clauses))) - ,(body (cdar clauses)) - ,(each-clause (cdr clauses)))))) - - `(,let ((,result ,key)) ,(each-clause clauses))) - -(define-syntax (do variables test . commands) - (let ((body - `(,begin ,@commands - (,rec ,@(map (lambda (x) - (if (pair? (cddr x)) - (car (cddr x)) - (car x))) - variables))))) - `(,let ,rec ,(map (lambda (x) - (list (car x) - (cadr x))) - variables) - ,(if (null? (cdr test)) - `(,let ((,result ,(car test))) - (,if ,result ,result ,body)) - `(,if ,(car test) (,begin ,@(cdr test)) ,body))))) +(define-syntax case + (hygienic-macro-transformer + (lambda (case key . clauses) + (define (body expressions) + (cond ((null? expressions) result) + ((free-identifier=? => (car expressions)) `(,(cadr expressions) ,result)) + (else `(,begin ,@expressions)))) + (define (each-clause clauses) + (cond ((null? clauses) (unspecified)) + ((free-identifier=? else (caar clauses)) + (body (cdar clauses))) + ((and (pair? (caar clauses)) + (null? (cdr (caar clauses)))) + `(,if (,eqv? ,result (,quote ,(car (caar clauses)))) + ,(body (cdar clauses)) + ,(each-clause (cdr clauses)))) + (else `(,if (,memv ,result (,quote ,(caar clauses))) + ,(body (cdar clauses)) + ,(each-clause (cdr clauses)))))) + `(,let ((,result ,key)) ,(each-clause clauses))))) + +(define-syntax do + (hygienic-macro-transformer + (lambda (do variables test . commands) + (let ((body `(,begin ,@commands + (,rec ,@(map (lambda (x) + (if (pair? (cddr x)) + (car (cddr x)) + (car x))) + variables))))) + `(,let ,rec ,(map (lambda (x) + (list (car x) + (cadr x))) + variables) + ,(if (null? (cdr test)) + `(,let ((,result ,(car test))) + (,if ,result ,result ,body)) + `(,if ,(car test) (,begin ,@(cdr test)) ,body))))))) ; ---- 6.1. Equivalence predicates --------------------------------------------- diff --git a/basis/r7rs.ss b/basis/r7rs.ss index c9e506678..c5b8c923e 100644 --- a/basis/r7rs.ss +++ b/basis/r7rs.ss @@ -141,13 +141,15 @@ ; (let-values "bind" ; bindings (tmp ... (a x)) body)))))) -(define-syntax (let-values bindings . body) - (if (null? bindings) - (list let '() . body) - (list call-with-values - (list lambda () (cadar bindings)) - (list lambda (caar bindings) - (list let-values (cdr bindings) . body))))) +(define-syntax let-values + (hygienic-macro-transformer + (lambda (let-values bindings . body) + (if (null? bindings) + (list let '() . body) + (list call-with-values + (list lambda () (cadar bindings)) + (list lambda (caar bindings) + (list let-values (cdr bindings) . body))))))) ; (define-syntax let*-values ; (syntax-rules () @@ -159,11 +161,13 @@ ; (let*-values (binding1 ...) ; body0 body1 ...))))) -(define-syntax (let*-values bindings . body) - (if (null? bindings) - (list let '() . body) - (list let-values (list (car bindings)) - (list let*-values (cdr bindings) . body)))) +(define-syntax let*-values + (hygienic-macro-transformer + (lambda (let*-values bindings . body) + (if (null? bindings) + (list let '() . body) + (list let-values (list (car bindings)) + (list let*-values (cdr bindings) . body)))))) ; ---- 4.2.3. Sequencing ------------------------------------------------------- diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index dd336ec42..44ff68f27 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -74,8 +74,10 @@ ; (list ,@(map cadr bindings)) ; (lambda () ,@body)))))) -(define-syntax (parameterize bindings . body) - `(,dynamic-bind - (,list ,@(map car bindings)) - (,list ,@(map cadr bindings)) - (,lambda () ,@body))) +(define-syntax parameterize + (hygienic-macro-transformer + (lambda (parameterize bindings . body) + `(,dynamic-bind + (,list ,@(map car bindings)) + (,list ,@(map cadr bindings)) + (,lambda () ,@body))))) diff --git a/basis/srfi-45.ss b/basis/srfi-45.ss index 1d2ea757d..e24bf7029 100644 --- a/basis/srfi-45.ss +++ b/basis/srfi-45.ss @@ -24,11 +24,15 @@ (promise-merge! new promise)) (force promise)))) -(define-syntax (lazy expression) - (list promise #f (list lambda '() expression))) - -(define-syntax (delay expression) - (list lazy (list promise #t expression))) +(define-syntax lazy + (hygienic-macro-transformer + (lambda (lazy expression) + (list promise #f (list lambda '() expression))))) + +(define-syntax delay + (hygienic-macro-transformer + (lambda (delay expression) + (list lazy (list promise #t expression))))) (define (make-promise x) (if (promise? x) x diff --git a/basis/srfi-78.ss b/basis/srfi-78.ss index 2894b48c7..489a7ad78 100644 --- a/basis/srfi-78.ss +++ b/basis/srfi-78.ss @@ -177,15 +177,15 @@ ; (if (>= check:mode 1) ; (check:proc 'expr (lambda () expr) equal expected))))) -(define-syntax (check expr rule expected) - (cond ((free-identifier=? => rule) - `(,check ,expr (,=> ,equal?) ,expected)) - - ((free-identifier=? => (car rule)) - (if (<= 1 check:mode) - `(,check:proc ',expr (,lambda () ,expr) ,(cadr rule) ',expected))) - - (else (unspecified)))) +(define-syntax check + (hygienic-macro-transformer + (lambda (check expr rule expected) + (cond ((free-identifier=? => rule) + `(,check ,expr (,=> ,equal?) ,expected)) + ((free-identifier=? => (car rule)) + (if (<= 1 check:mode) + `(,check:proc ',expr (,lambda () ,expr) ,(cadr rule) ',expected))) + (else (unspecified)))))) ; -- parametric checks -- diff --git a/basis/srfi-8.ss b/basis/srfi-8.ss index eb66bc47d..6112aafc2 100644 --- a/basis/srfi-8.ss +++ b/basis/srfi-8.ss @@ -12,8 +12,10 @@ ; (,(rename 'lambda) () ,(caddr form)) ; (,(rename 'lambda) ,(cadr form) ,@(cdddr form)))))) -(define-syntax (receive parameters expression . body) - (define (list . xs) xs) - (list call-with-values - (list lambda '() expression) - (list lambda parameters . body))) +(define-syntax receive + (hygienic-macro-transformer + (lambda (receive parameters expression . body) + (define (list . xs) xs) + (list call-with-values + (list lambda '() expression) + (list lambda parameters . body))))) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 064b1d761..d488afee8 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -70,6 +70,21 @@ inline namespace kernel expander.reset(); } + explicit hygienic_macro_transformer(const_reference transform, + const_reference current_syntactic_environment, + environment const& current_environment) + : transform { transform } + , expander { current_environment } + { + assert(transform.is()); + + expander.syntactic_environment() = current_syntactic_environment; + + expander.s = unit; + expander.c = list(make(mnemonic::stop)); + expander.d = unit; + } + auto expand(let const& form) /* ------------------------------------------ * * Scheme programs can define and use new derived expression types, diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index d39acb131..e320badbc 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1922,6 +1922,11 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { + define("hygienic-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) + { + return make(car(xs), current_syntactic_environment, current_environment); + }); + define("%er-macro-transformer", [](let const& xs, let const&, environment & current_environment) { return make(car(xs), current_environment); @@ -1932,12 +1937,10 @@ namespace meevax return car(xs).is(); }); - define("identifier", [](let const& xs, - let const& current_syntactic_environment, - auto & environment) + define("identifier", [](let const& xs, let const& current_syntactic_environment, auto&& current_environment) { assert(car(xs).is()); - return environment.rename(car(xs), current_syntactic_environment); + return current_environment.rename(car(xs), current_syntactic_environment); }); /* ------------------------------------------------------------------------- diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index e47023880..e3e545a8a 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -17,10 +17,12 @@ ; ------------------------------------------------------------------------------ -(define-syntax (swap! a b) - `(,let ((,x ,a)) - (,set! ,a ,b) - (,set! ,b ,x))) +(define-syntax swap! + (hygienic-macro-transformer + (lambda (swap! a b) + `(,let ((,x ,a)) + (,set! ,a ,b) + (,set! ,b ,x))))) (define x 1) diff --git a/test/r7rs.ss b/test/r7rs.ss index 479ba9d9a..9f37a5305 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -1197,10 +1197,6 @@ (check (eval '(+ 1 2 3) (current-environment-specifier)) => 6) -(define-syntax (increment x . n) - (let ((n (if (pair? n) (car n) 1))) - `(,begin (,set! ,x (,+ ,x ,n)) ,x))) - ; ------------------------------------------------------------------------------ (check-report) From d226699110765c596294b755b7c2f85a1854b1ee Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 3 Apr 2022 21:16:28 +0900 Subject: [PATCH 081/118] Remove R4RS-APPENDIX syntax `syntax` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 7 ------- test/r4rs-appendix.ss | 4 ++-- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 8c0467069..b38e932e2 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.907.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.908.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.907_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.908_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.907 +Meevax Lisp System, version 0.3.908 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7f70fcabf..bdc125e5d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.907 +0.3.908 diff --git a/basis/overture.ss b/basis/overture.ss index 44952eb90..d87d74a6f 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -9,13 +9,6 @@ (lambda (import . import-sets) (list quote (cons 'import import-sets))))) -(define-syntax syntax - (hygienic-macro-transformer - (lambda (syntax datum) - (if (pair? datum) - (list fork/csc (list lambda '() datum)) - (eval datum (fork/csc identity)))))) - (define (current-environment-specifier) (fork/csc identity)) diff --git a/test/r4rs-appendix.ss b/test/r4rs-appendix.ss index 99fd5420e..dc62d0f7f 100644 --- a/test/r4rs-appendix.ss +++ b/test/r4rs-appendix.ss @@ -1,4 +1,4 @@ -(check (symbol? (syntax x)) => #f) +; (check (symbol? (syntax x)) => #f) ; (check ; (let-syntax ((car @@ -69,7 +69,7 @@ ; (alpha))) ; => error) -(check (identifier? (syntax x)) => #t) +; (check (identifier? (syntax x)) => #t) ; (check (identifier? (quote x)) => #f) (check (identifier? 3) => #f) From 89bc1587f1aa967846150a3154249fa743abaeb8 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 4 Apr 2022 20:04:43 +0900 Subject: [PATCH 082/118] Move data member `expander` into base class `macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 31 ++++++++++++++++++++----------- src/library/meevax.cpp | 4 ++-- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b38e932e2..c3d3f9f50 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.908.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.909.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.908_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.909_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.908 +Meevax Lisp System, version 0.3.909 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index bdc125e5d..a5b093df5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.908 +0.3.909 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index d488afee8..11d9f7c9b 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -49,16 +49,25 @@ inline namespace kernel d; // dump (s e c . d) struct macro_transformer - {}; + { + environment expander; + + explicit macro_transformer(const_reference current_syntactic_environment, + environment const& current_environment) + : expander { current_environment } + { + expander.syntactic_environment() = current_syntactic_environment; + } + }; struct hygienic_macro_transformer : public macro_transformer { let transform; - environment expander; + using macro_transformer::expander; explicit hygienic_macro_transformer(environment const& current_environment) - : expander { current_environment } + : macro_transformer { current_environment.syntactic_environment(), current_environment } { expander.c = compile(context::outermost, expander, @@ -73,13 +82,11 @@ inline namespace kernel explicit hygienic_macro_transformer(const_reference transform, const_reference current_syntactic_environment, environment const& current_environment) - : transform { transform } - , expander { current_environment } + : macro_transformer { current_syntactic_environment, current_environment } + , transform { transform } { assert(transform.is()); - expander.syntactic_environment() = current_syntactic_environment; - expander.s = unit; expander.c = list(make(mnemonic::stop)); expander.d = unit; @@ -140,11 +147,13 @@ inline namespace kernel { let const transform; - environment expander; + using macro_transformer::expander; - explicit er_macro_transformer(let const& transform, environment const& current_environment) - : transform { transform } - , expander { current_environment } + explicit er_macro_transformer(const_reference transform, + const_reference current_syntactic_environment, + environment const& current_environment) + : macro_transformer { current_syntactic_environment, current_environment } + , transform { transform } { assert(transform.is()); diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index e320badbc..edbb33d01 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1927,9 +1927,9 @@ namespace meevax return make(car(xs), current_syntactic_environment, current_environment); }); - define("%er-macro-transformer", [](let const& xs, let const&, environment & current_environment) + define("%er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { - return make(car(xs), current_environment); + return make(car(xs), current_syntactic_environment, current_environment); }); define("er-macro-transformer?", [](let const& xs, auto&&...) From 0df13cf3075785e0f8f69c394a78dd725a979a2d Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 02:56:38 +0900 Subject: [PATCH 083/118] Replace `fork/csc` with `hygienic-macro-transformer` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- basis/overture.ss | 10 +++--- basis/r7rs.ss | 4 --- include/meevax/kernel/machine.hpp | 55 ++++--------------------------- test/abandoned.ss | 16 ++++----- test/er-macro-transformer.ss | 19 ----------- test/let-syntax.ss | 8 ----- test/low-level-macro-facility.ss | 2 +- 9 files changed, 24 insertions(+), 98 deletions(-) diff --git a/README.md b/README.md index c3d3f9f50..738cca45a 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.909.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.910.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.909_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.910_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.909 +Meevax Lisp System, version 0.3.910 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index a5b093df5..1fd5ec30c 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.909 +0.3.910 diff --git a/basis/overture.ss b/basis/overture.ss index d87d74a6f..d42cada1c 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -2,18 +2,16 @@ (define (list . xs) xs) -(define fork/csc fork-with-current-syntactic-continuation) - -(define import - (fork/csc +(define-syntax import + (hygienic-macro-transformer (lambda (import . import-sets) (list quote (cons 'import import-sets))))) (define (current-environment-specifier) - (fork/csc identity)) + (hygienic-macro-transformer identity)) (define (er-macro-transformer transform) - (fork/csc + (hygienic-macro-transformer (lambda form (transform form (lambda (x) (eval x (car form))) free-identifier=?)))) diff --git a/basis/r7rs.ss b/basis/r7rs.ss index c5b8c923e..6fbce1fb2 100644 --- a/basis/r7rs.ss +++ b/basis/r7rs.ss @@ -423,7 +423,3 @@ parameterize ; is defined in srfi-39.ss ; TODO current-second ; TODO current-jiffy ; TODO jiffies-per-second - -(define interaction-environment - (let ((e (fork/csc identity))) - (lambda () e))) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 11d9f7c9b..9e163c92f 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -139,7 +139,7 @@ inline namespace kernel friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & { - return os << magenta("#,(") << green("fork/csc ") << faint("#;", &datum) << magenta(")"); + return os << magenta("#,(") << green("hygienic-macro-transformer ") << faint("#;", &datum) << magenta(")"); } }; @@ -1052,53 +1052,12 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - // if (current_syntactic_environment.is() or (current_context & context::outermost)) - // { - // if (car(current_expression).is()) // (define-syntax ( . ) ) - // { - // return compile(context::none, - // current_environment, - // list(make("fork/csc", fork_csc), - // cons(make("lambda", lambda), current_expression)), - // current_syntactic_environment, - // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(caar(current_expression))), - // current_continuation)); - // } - // else // (define-syntax x ...) - // { - // return compile(context::none, - // current_environment, - // cdr(current_expression) ? cadr(current_expression) : throw syntax_error(make("define-syntax: no specified")), - // current_syntactic_environment, - // cons(make(mnemonic::define_syntax), cons(current_syntactic_environment, current_environment.notate(car(current_expression))), - // current_continuation)); - // } - // } - // else - // { - // throw syntax_error(make("definition cannot appear in this syntactic-context")); - // } - - if (car(current_expression).is()) // (define-syntax ( . xs) ) - { - return define(current_context, - current_environment, - list(caar(current_expression), - list(make("fork/csc", fork_csc), - cons(make("lambda", lambda), current_expression) - ) - ), - current_syntactic_environment, - current_continuation); - } - else - { - return define(current_context, - current_environment, - current_expression, - current_syntactic_environment, - current_continuation); - } + return compile(context::none, + current_environment, + cdr(current_expression) ? cadr(current_expression) : unspecified_object, + current_syntactic_environment, + cons(make(mnemonic::define_syntax), current_environment.notate(car(current_expression), current_syntactic_environment), + current_continuation)); } static SYNTAX(fork_csc) /* ------------------------------------------------- diff --git a/test/abandoned.ss b/test/abandoned.ss index 82e7e119b..7cff409c3 100644 --- a/test/abandoned.ss +++ b/test/abandoned.ss @@ -72,14 +72,14 @@ (let ((s "abcde")) (check (begin (string-fill! s #\x 1) s) => "axxxx")) (let ((s "abcde")) (check (begin (string-fill! s #\x 1 4) s) => "axxxe")) -(define loop - (fork/csc - (lambda form - `(,call/cc - (,lambda (exit) - (,let ,rec () - ,(cadr form) - (,rec)))) ))) +(define-syntax loop + (er-macro-transformer + (lambda (form rename compare) + `(,(rename 'call/cc) + (,(rename 'lambda) (exit) + (,(rename 'let) ,(rename 'rec) () + ,(cadr form) + (,(rename 'rec)))))))) (define f (lambda () diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index e3e545a8a..d838969e1 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,22 +1,3 @@ -(define-syntax swap! - (fork/csc - (lambda (swap! a b) - `(,let ((,x ,a)) - (,set! ,a ,b) - (,set! ,b ,x))))) - -(define x 1) - -(define y 2) - -(check (cons x y) => (1 . 2)) - -(swap! x y) - -(check (cons x y) => (2 . 1)) - -; ------------------------------------------------------------------------------ - (define-syntax swap! (hygienic-macro-transformer (lambda (swap! a b) diff --git a/test/let-syntax.ss b/test/let-syntax.ss index 7785f25b7..ec305c7fb 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -42,14 +42,6 @@ ; ------------------------------------------------------------------------------ -; (check (let ((x 'outer)) -; (let-syntax ((m (fork/csc -; (lambda (this) x)))) -; (let ((x 'inner)) -; (m)))) => outer) - -; ------------------------------------------------------------------------------ - ; (check (let ((x 'outer)) ; (let-syntax ((m (er-macro-transformer ; (lambda (form rename compare) diff --git a/test/low-level-macro-facility.ss b/test/low-level-macro-facility.ss index 1a07f46b6..737d0633c 100644 --- a/test/low-level-macro-facility.ss +++ b/test/low-level-macro-facility.ss @@ -5,7 +5,7 @@ ; (define hygienic-x (syntax x)) (define rename - (let ((e (fork/csc identity))) + (let ((e (hygienic-macro-transformer list))) (lambda (x) (eval x e)))) From ab2332a2a828d486d9ef1f9f50afecba3d944063 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 03:19:34 +0900 Subject: [PATCH 084/118] Remove syntax `fork-with-current-syntactic-continuation` --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/instruction.hpp | 1 - include/meevax/kernel/machine.hpp | 37 --------------------------- src/kernel/instruction.cpp | 2 -- src/library/meevax.cpp | 1 - 6 files changed, 4 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 738cca45a..6f57387e8 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.910.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.911.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.910_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.911_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.910 +Meevax Lisp System, version 0.3.911 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1fd5ec30c..f60170256 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.910 +0.3.911 diff --git a/include/meevax/kernel/instruction.hpp b/include/meevax/kernel/instruction.hpp index 8b795fb60..4bcf2a372 100644 --- a/include/meevax/kernel/instruction.hpp +++ b/include/meevax/kernel/instruction.hpp @@ -31,7 +31,6 @@ inline namespace kernel define_syntax, // drop, // dummy, // a.k.a DUM - fork, // join, // let_syntax, // letrec, // a.k.a RAP diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 9e163c92f..6d666b881 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -66,19 +66,6 @@ inline namespace kernel using macro_transformer::expander; - explicit hygienic_macro_transformer(environment const& current_environment) - : macro_transformer { current_environment.syntactic_environment(), current_environment } - { - expander.c = compile(context::outermost, - expander, - cadr(expander.c).template as().expression(), - cadr(expander.c).template as().syntactic_environment()); - - transform = expander.execute(); - - expander.reset(); - } - explicit hygienic_macro_transformer(const_reference transform, const_reference current_syntactic_environment, environment const& current_environment) @@ -409,15 +396,6 @@ inline namespace kernel c = cddr(c); goto decode; - case mnemonic::fork: /* -------------------------------------------------- - * - * s e (%fork c1 . c2) d => ( . s) e c2 d - * - * ------------------------------------------------------------------- */ - s = cons(make(static_cast(*this)), s); - c = cddr(c); - goto decode; - case mnemonic::select: /* ------------------------------------------------ * * ( . s) e (%select c1 c2 . c) d => s e c' (c . d) @@ -1060,21 +1038,6 @@ inline namespace kernel current_continuation)); } - static SYNTAX(fork_csc) /* ------------------------------------------------- - * - * (fork-with-current-syntactic-continuation ) syntax - * - * Semantics: The syntax fork-with-current-syntactic-continuation packages - * the given definition and the continuation of the current - * compilation as a "subprogram". - * - * ----------------------------------------------------------------------- */ - { - return cons(make(mnemonic::fork), - make(car(current_expression), current_syntactic_environment), - current_continuation); - } - static SYNTAX(lambda) /* --------------------------------------------------- * * (lambda ) syntax diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index d66bf5ef4..5799f97af 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -31,7 +31,6 @@ inline namespace kernel case mnemonic::define_syntax: return "define-syntax"; case mnemonic::drop: return "drop"; case mnemonic::dummy: return "dummy"; - case mnemonic::fork: return "fork"; case mnemonic::join: return "join"; case mnemonic::let_syntax: return "let-syntax"; case mnemonic::letrec: return "letrec"; @@ -99,7 +98,6 @@ inline namespace kernel case mnemonic::call: case mnemonic::define: case mnemonic::define_syntax: - case mnemonic::fork: case mnemonic::let_syntax: case mnemonic::letrec_syntax: case mnemonic::load_absolute: diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index edbb33d01..6553cf3b6 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -27,7 +27,6 @@ namespace meevax define("call-with-current-continuation!", call_with_current_continuation); define("define", machine::define); define("define-syntax", define_syntax); - define("fork-with-current-syntactic-continuation", fork_csc); define("if", if_); define("lambda", lambda); define("let-syntax", let_syntax); From 63a609b6b8b9bd1137207bfe324d5e81f5e7251a Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 03:38:31 +0900 Subject: [PATCH 085/118] Move transformer's data member `transform` into base class `macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 43 ++++++++++--------------------- 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 6f57387e8..e36c71efa 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.911.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.912.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.911_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.912_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.911 +Meevax Lisp System, version 0.3.912 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f60170256..1811d9dd4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.911 +0.3.912 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 6d666b881..d76f28095 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -50,34 +50,28 @@ inline namespace kernel struct macro_transformer { + let const transform; + environment expander; - explicit macro_transformer(const_reference current_syntactic_environment, + explicit macro_transformer(const_reference transform, + const_reference current_syntactic_environment, environment const& current_environment) - : expander { current_environment } + : transform { transform } + , expander { current_environment } { + assert(transform.is()); + expander.syntactic_environment() = current_syntactic_environment; + expander.reset(); } }; struct hygienic_macro_transformer : public macro_transformer { - let transform; - using macro_transformer::expander; - - explicit hygienic_macro_transformer(const_reference transform, - const_reference current_syntactic_environment, - environment const& current_environment) - : macro_transformer { current_syntactic_environment, current_environment } - , transform { transform } - { - assert(transform.is()); - - expander.s = unit; - expander.c = list(make(mnemonic::stop)); - expander.d = unit; - } + using macro_transformer::macro_transformer; + using macro_transformer::transform; auto expand(let const& form) /* ------------------------------------------ * @@ -132,20 +126,9 @@ inline namespace kernel struct er_macro_transformer : public macro_transformer { - let const transform; - using macro_transformer::expander; - - explicit er_macro_transformer(const_reference transform, - const_reference current_syntactic_environment, - environment const& current_environment) - : macro_transformer { current_syntactic_environment, current_environment } - , transform { transform } - { - assert(transform.is()); - - expander.reset(); - } + using macro_transformer::macro_transformer; + using macro_transformer::transform; auto expand(let const& form, environment &) { From eb848673097dd1b3f20cc4701c9424815e17a505 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 03:51:25 +0900 Subject: [PATCH 086/118] Add pure virtual member function `macro_transformer::expand` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 31 +++++++++++-------------------- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index e36c71efa..42d3164e6 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.912.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.913.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.912_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.913_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.912 +Meevax Lisp System, version 0.3.913 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1811d9dd4..7bd195bf3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.912 +0.3.913 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index d76f28095..62abc06d4 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -65,15 +65,8 @@ inline namespace kernel expander.syntactic_environment() = current_syntactic_environment; expander.reset(); } - }; - - struct hygienic_macro_transformer : public macro_transformer - { - using macro_transformer::expander; - using macro_transformer::macro_transformer; - using macro_transformer::transform; - auto expand(let const& form) /* ------------------------------------------ + virtual auto expand(const_reference) -> object = 0; /* ------------------- * * Scheme programs can define and use new derived expression types, * called macros. Program-defined expression types have the syntax @@ -103,18 +96,16 @@ inline namespace kernel * environment::evaluate. * * --------------------------------------------------------------------- */ - { - assert(transform.template is()); - - assert(expander.d.template is()); - assert(expander.c.template is()); - assert(expander.e.template is()); - assert(expander.s.template is()); + }; - assert(car(expander.c).template is()); - assert(car(expander.c).template as().value == mnemonic::stop); - assert(cdr(expander.c).template is()); + struct hygienic_macro_transformer : public macro_transformer + { + using macro_transformer::expander; + using macro_transformer::macro_transformer; + using macro_transformer::transform; + auto expand(const_reference form) -> object override + { return expander.apply(transform, form); } @@ -130,7 +121,7 @@ inline namespace kernel using macro_transformer::macro_transformer; using macro_transformer::transform; - auto expand(let const& form, environment &) + auto expand(const_reference form) -> object override { auto rename = make("rename", [](let const& xs, auto&&, auto&& expander) { @@ -247,7 +238,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().expand(current_expression, current_environment), + applicant.as().expand(current_expression), current_syntactic_environment, current_continuation); } From 562487be52d8299f4cdb4b5bc96979cfd2df5d32 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 04:02:32 +0900 Subject: [PATCH 087/118] Rename struct `macro_transformer` to `transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 24 ++++++++++++------------ src/library/meevax.cpp | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 42d3164e6..5cbdd7249 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.913.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.914.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.913_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.914_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.913 +Meevax Lisp System, version 0.3.914 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7bd195bf3..44540cfcc 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.913 +0.3.914 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 62abc06d4..afc8eb53d 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -48,15 +48,15 @@ inline namespace kernel c, // code (instructions yet to be executed) d; // dump (s e c . d) - struct macro_transformer + struct transformer { let const transform; environment expander; - explicit macro_transformer(const_reference transform, - const_reference current_syntactic_environment, - environment const& current_environment) + explicit transformer(const_reference transform, + const_reference current_syntactic_environment, + environment const& current_environment) : transform { transform } , expander { current_environment } { @@ -98,11 +98,11 @@ inline namespace kernel * --------------------------------------------------------------------- */ }; - struct hygienic_macro_transformer : public macro_transformer + struct hygienic_macro_transformer : public transformer { - using macro_transformer::expander; - using macro_transformer::macro_transformer; - using macro_transformer::transform; + using transformer::expander; + using transformer::transformer; + using transformer::transform; auto expand(const_reference form) -> object override { @@ -115,11 +115,11 @@ inline namespace kernel } }; - struct er_macro_transformer : public macro_transformer + struct er_macro_transformer : public transformer { - using macro_transformer::expander; - using macro_transformer::macro_transformer; - using macro_transformer::transform; + using transformer::expander; + using transformer::transformer; + using transformer::transform; auto expand(const_reference form) -> object override { diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 6553cf3b6..feeb01c66 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2091,7 +2091,7 @@ namespace meevax define("transformer?", [](let const& xs, auto&&...) { - return car(xs).is_also(); + return car(xs).is_also(); }); define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) From 58d6b4d659cbd0ec7a583b0bb095a2d8b12d94b6 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 22:09:29 +0900 Subject: [PATCH 088/118] Update compiler to recognize virtual base class `transformer` instead of` hygienic_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/srfi-149.ss | 2 +- basis/srfi-39.ss | 2 +- basis/srfi-8.ss | 2 +- include/meevax/kernel/machine.hpp | 20 ++++++-------------- src/library/meevax.cpp | 6 +++--- test/abandoned.ss | 9 +++++++-- test/chibi-basic.ss | 6 +++--- test/er-macro-transformer.ss | 21 --------------------- test/let-syntax.ss | 10 +++++----- test/letrec-syntax.ss | 4 ++-- test/low-level-macro-facility.ss | 4 +--- test/r7rs.ss | 4 ++-- 14 files changed, 36 insertions(+), 62 deletions(-) diff --git a/README.md b/README.md index 5cbdd7249..e0204a027 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.914.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.915.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.914_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.915_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.914 +Meevax Lisp System, version 0.3.915 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 44540cfcc..fea3d1e33 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.914 +0.3.915 diff --git a/basis/srfi-149.ss b/basis/srfi-149.ss index c8f0b3c16..108ebd321 100644 --- a/basis/srfi-149.ss +++ b/basis/srfi-149.ss @@ -268,6 +268,6 @@ #f))))))))) (define-syntax syntax-rules - (er-macro-transformer + (%er-macro-transformer (lambda (form rename compare) (syntax-rules-transformer form rename compare)))) diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index 44ff68f27..d4fcb9d06 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -65,7 +65,7 @@ (set! dynamic-env-local new-env)) ; (define-syntax parameterize -; (er-macro-transformer +; (%er-macro-transformer ; (lambda (form rename compare) ; (let* ((bindings (cadr form)) ; (body (cddr form))) diff --git a/basis/srfi-8.ss b/basis/srfi-8.ss index 6112aafc2..f369dad37 100644 --- a/basis/srfi-8.ss +++ b/basis/srfi-8.ss @@ -6,7 +6,7 @@ ; (lambda parameters . body))))) ; (define-syntax receive -; (er-macro-transformer +; (%er-macro-transformer ; (lambda (form rename compare) ; `(call-with-values ; (,(rename 'lambda) () ,(caddr form)) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index afc8eb53d..4458b36bc 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -129,9 +129,9 @@ inline namespace kernel return expander.evaluate(car(xs)); }); - auto compare = make("compare", [](let const& xs, let const&, environment &) + auto compare = make("compare", [](let const& xs, let const&, environment & expander) { - return eqv(car(xs), cadr(xs)); + return expander.is_same_free_identifier(car(xs), cadr(xs)); }); return expander.apply(transform, list(form, rename, compare)); @@ -210,11 +210,11 @@ inline namespace kernel } else if (let const& notation = std::as_const(current_environment).notate(car(current_expression), current_syntactic_environment); notation.is()) { - assert(notation.as().strip().is()); + assert(notation.as().strip().is_also()); return compile(context::none, current_environment, - notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), + notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), current_syntactic_environment, current_continuation); } @@ -226,19 +226,11 @@ inline namespace kernel current_syntactic_environment, current_continuation); } - else if (applicant.is()) + else if (applicant.is_also()) { return compile(context::none, current_environment, - applicant.as().expand(cons(applicant, cdr(current_expression))), - current_syntactic_environment, - current_continuation); - } - else if (applicant.is()) - { - return compile(context::none, - current_environment, - applicant.as().expand(current_expression), + applicant.as().expand(cons(applicant, cdr(current_expression))), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index feeb01c66..5bacdf3ea 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1671,7 +1671,7 @@ namespace meevax define("eval", [](let const& xs, auto&&...) { - return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! + return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! }); } @@ -2096,9 +2096,9 @@ namespace meevax define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) { - if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is()) + if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is_also()) { - return macro.as().expand(cons(macro, cdar(xs))); + return macro.as().expand(cons(macro, cdar(xs))); } else { diff --git a/test/abandoned.ss b/test/abandoned.ss index 7cff409c3..e8209bd98 100644 --- a/test/abandoned.ss +++ b/test/abandoned.ss @@ -15,7 +15,6 @@ (check (string=? (make-string 3) "") => #f) -(check (string=? (make-string 3) " ") => #t) (check (string=? (make-string 3 #\a) "aaa") => #t) (check (string=? (string) "") => #t) @@ -73,7 +72,7 @@ (let ((s "abcde")) (check (begin (string-fill! s #\x 1 4) s) => "axxxe")) (define-syntax loop - (er-macro-transformer + (%er-macro-transformer (lambda (form rename compare) `(,(rename 'call/cc) (,(rename 'lambda) (exit) @@ -116,3 +115,9 @@ ; (let loop () ; ,(make-syntactic-closure environment '(exit) (cadr form)) ; (loop))))))) + +; ------------------------------------------------------------------------------ + +(check-report) + +(exit (check-passed? check:correct)) diff --git a/test/chibi-basic.ss b/test/chibi-basic.ss index 7475855e7..b522cb818 100644 --- a/test/chibi-basic.ss +++ b/test/chibi-basic.ss @@ -190,7 +190,7 @@ (check (letrec-syntax ((myor - (er-macro-transformer + (%er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f @@ -202,7 +202,7 @@ => 5) (define-syntax myor - (er-macro-transformer + (%er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f (list (rename 'let) (list (list (rename 'tmp) (cadr expr))) @@ -263,7 +263,7 @@ (check (letrec-syntax ((myor - (er-macro-transformer + (%er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index d838969e1..e3810b2b9 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -17,27 +17,6 @@ ; ------------------------------------------------------------------------------ -(define-syntax swap! - (er-macro-transformer - (lambda (form rename compare) - (let ((a (cadr form)) - (b (caddr form))) - `(,(rename 'let) ((,(rename 'x) ,a)) - (,(rename 'set!) ,a ,b) - (,(rename 'set!) ,b ,(rename 'x))))))) - -(define x 1) - -(define y 2) - -(check (cons x y) => (1 . 2)) - -(swap! x y) - -(check (cons x y) => (2 . 1)) - -; ------------------------------------------------------------------------------ - (define-syntax swap! (%er-macro-transformer (lambda (form rename compare) diff --git a/test/let-syntax.ss b/test/let-syntax.ss index ec305c7fb..3cdc5ea2e 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -10,10 +10,10 @@ (+ a 2)))) (set! result (cons (f 0) result)) - (let-syntax ((f (er-macro-transformer + (let-syntax ((f (%er-macro-transformer (lambda (form rename compare) `(,(rename '+) ,(cadr form) 3)))) - (g (er-macro-transformer + (g (%er-macro-transformer (lambda (form rename compare) '())))) (set! result (cons (f 0) result)) @@ -29,7 +29,7 @@ (define (double-y) (let ((+y (lambda (x) (+ x y)))) - (let-syntax ((macro (er-macro-transformer + (let-syntax ((macro (%er-macro-transformer (lambda (form rename compare) `(,(rename '+) ,(cadr form) ,(+y 0)))))) (macro y)))) @@ -43,7 +43,7 @@ ; ------------------------------------------------------------------------------ ; (check (let ((x 'outer)) -; (let-syntax ((m (er-macro-transformer +; (let-syntax ((m (%er-macro-transformer ; (lambda (form rename compare) ; (rename 'x))))) ; (let ((x 'inner)) @@ -51,7 +51,7 @@ ; ; (define result ; (let ((x 'outer)) -; (let-syntax ((m (er-macro-transformer +; (let-syntax ((m (%er-macro-transformer ; (lambda (form rename compare) ; (rename 'x))))) ; (let ((x 'inner)) diff --git a/test/letrec-syntax.ss b/test/letrec-syntax.ss index 1bc86ebdc..9dd2f9adf 100644 --- a/test/letrec-syntax.ss +++ b/test/letrec-syntax.ss @@ -2,7 +2,7 @@ (scheme base) (srfi 78)) -(letrec-syntax ((my-and (er-macro-transformer +(letrec-syntax ((my-and (%er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #t) ((null? (cddr form)) (cadr form)) @@ -12,7 +12,7 @@ #f))))))) (check (my-and #t #t #f #t) => #f)) -(letrec-syntax ((my-or (er-macro-transformer +(letrec-syntax ((my-or (%er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) diff --git a/test/low-level-macro-facility.ss b/test/low-level-macro-facility.ss index 737d0633c..9f8f10822 100644 --- a/test/low-level-macro-facility.ss +++ b/test/low-level-macro-facility.ss @@ -20,12 +20,10 @@ ; (,set! ,y ,value))) (define-syntax swap! - (er-macro-transformer + (%er-macro-transformer (lambda (form rename compare) - (check (transformer? (rename 'let)) => #t) (check (identifier? (rename 'value)) => #t) - (let ((a (cadr form)) (b (caddr form))) `(,(rename 'let) ((,(rename 'value) ,a)) diff --git a/test/r7rs.ss b/test/r7rs.ss index 9f37a5305..f1c40ad0c 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -356,7 +356,7 @@ (check (let ((x 'outer)) (let-syntax ((m ; (syntax-rules () ((m) x)) ; BUG - (er-macro-transformer + (%er-macro-transformer (lambda (form rename compare) (list (rename 'quote) x))))) (let ((x 'inner)) @@ -368,7 +368,7 @@ ; ((my-or e1 e2 ...) ; (let ((temp e1)) ; (if temp temp (my-or e2 ...))))) - (er-macro-transformer + (%er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) From b6ae22a8d33864573ccee4f448369b84f31a3dbc Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 5 Apr 2022 22:30:40 +0900 Subject: [PATCH 089/118] Rename procedure `%er-macro-transformer` to `er-macro-transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 5 ----- basis/srfi-149.ss | 2 +- basis/srfi-39.ss | 2 +- basis/srfi-8.ss | 2 +- src/library/meevax.cpp | 2 +- test/abandoned.ss | 2 +- test/chibi-basic.ss | 6 +++--- test/er-macro-transformer.ss | 2 +- test/let-syntax.ss | 10 +++++----- test/letrec-syntax.ss | 4 ++-- test/low-level-macro-facility.ss | 2 +- test/r7rs.ss | 4 ++-- 14 files changed, 23 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index e0204a027..123d1d089 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.915.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.916.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.915_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.916_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.915 +Meevax Lisp System, version 0.3.916 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index fea3d1e33..f0ad0fd58 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.915 +0.3.916 diff --git a/basis/overture.ss b/basis/overture.ss index d42cada1c..c0caf2606 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -10,11 +10,6 @@ (define (current-environment-specifier) (hygienic-macro-transformer identity)) -(define (er-macro-transformer transform) - (hygienic-macro-transformer - (lambda form - (transform form (lambda (x) (eval x (car form))) free-identifier=?)))) - (define (unspecified) (if #f #f)) (define-syntax cond diff --git a/basis/srfi-149.ss b/basis/srfi-149.ss index 108ebd321..c8f0b3c16 100644 --- a/basis/srfi-149.ss +++ b/basis/srfi-149.ss @@ -268,6 +268,6 @@ #f))))))))) (define-syntax syntax-rules - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) (syntax-rules-transformer form rename compare)))) diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index d4fcb9d06..44ff68f27 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -65,7 +65,7 @@ (set! dynamic-env-local new-env)) ; (define-syntax parameterize -; (%er-macro-transformer +; (er-macro-transformer ; (lambda (form rename compare) ; (let* ((bindings (cadr form)) ; (body (cddr form))) diff --git a/basis/srfi-8.ss b/basis/srfi-8.ss index f369dad37..6112aafc2 100644 --- a/basis/srfi-8.ss +++ b/basis/srfi-8.ss @@ -6,7 +6,7 @@ ; (lambda parameters . body))))) ; (define-syntax receive -; (%er-macro-transformer +; (er-macro-transformer ; (lambda (form rename compare) ; `(call-with-values ; (,(rename 'lambda) () ,(caddr form)) diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 5bacdf3ea..a789ab15b 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1926,7 +1926,7 @@ namespace meevax return make(car(xs), current_syntactic_environment, current_environment); }); - define("%er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) + define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { return make(car(xs), current_syntactic_environment, current_environment); }); diff --git a/test/abandoned.ss b/test/abandoned.ss index e8209bd98..c80005009 100644 --- a/test/abandoned.ss +++ b/test/abandoned.ss @@ -72,7 +72,7 @@ (let ((s "abcde")) (check (begin (string-fill! s #\x 1 4) s) => "axxxe")) (define-syntax loop - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) `(,(rename 'call/cc) (,(rename 'lambda) (exit) diff --git a/test/chibi-basic.ss b/test/chibi-basic.ss index b522cb818..7475855e7 100644 --- a/test/chibi-basic.ss +++ b/test/chibi-basic.ss @@ -190,7 +190,7 @@ (check (letrec-syntax ((myor - (%er-macro-transformer + (er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f @@ -202,7 +202,7 @@ => 5) (define-syntax myor - (%er-macro-transformer + (er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f (list (rename 'let) (list (list (rename 'tmp) (cadr expr))) @@ -263,7 +263,7 @@ (check (letrec-syntax ((myor - (%er-macro-transformer + (er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index e3810b2b9..e54c78970 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -18,7 +18,7 @@ ; ------------------------------------------------------------------------------ (define-syntax swap! - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) (let ((a (cadr form)) (b (caddr form))) diff --git a/test/let-syntax.ss b/test/let-syntax.ss index 3cdc5ea2e..ec305c7fb 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -10,10 +10,10 @@ (+ a 2)))) (set! result (cons (f 0) result)) - (let-syntax ((f (%er-macro-transformer + (let-syntax ((f (er-macro-transformer (lambda (form rename compare) `(,(rename '+) ,(cadr form) 3)))) - (g (%er-macro-transformer + (g (er-macro-transformer (lambda (form rename compare) '())))) (set! result (cons (f 0) result)) @@ -29,7 +29,7 @@ (define (double-y) (let ((+y (lambda (x) (+ x y)))) - (let-syntax ((macro (%er-macro-transformer + (let-syntax ((macro (er-macro-transformer (lambda (form rename compare) `(,(rename '+) ,(cadr form) ,(+y 0)))))) (macro y)))) @@ -43,7 +43,7 @@ ; ------------------------------------------------------------------------------ ; (check (let ((x 'outer)) -; (let-syntax ((m (%er-macro-transformer +; (let-syntax ((m (er-macro-transformer ; (lambda (form rename compare) ; (rename 'x))))) ; (let ((x 'inner)) @@ -51,7 +51,7 @@ ; ; (define result ; (let ((x 'outer)) -; (let-syntax ((m (%er-macro-transformer +; (let-syntax ((m (er-macro-transformer ; (lambda (form rename compare) ; (rename 'x))))) ; (let ((x 'inner)) diff --git a/test/letrec-syntax.ss b/test/letrec-syntax.ss index 9dd2f9adf..1bc86ebdc 100644 --- a/test/letrec-syntax.ss +++ b/test/letrec-syntax.ss @@ -2,7 +2,7 @@ (scheme base) (srfi 78)) -(letrec-syntax ((my-and (%er-macro-transformer +(letrec-syntax ((my-and (er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #t) ((null? (cddr form)) (cadr form)) @@ -12,7 +12,7 @@ #f))))))) (check (my-and #t #t #f #t) => #f)) -(letrec-syntax ((my-or (%er-macro-transformer +(letrec-syntax ((my-or (er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) diff --git a/test/low-level-macro-facility.ss b/test/low-level-macro-facility.ss index 9f8f10822..d38125ad6 100644 --- a/test/low-level-macro-facility.ss +++ b/test/low-level-macro-facility.ss @@ -20,7 +20,7 @@ ; (,set! ,y ,value))) (define-syntax swap! - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) (check (transformer? (rename 'let)) => #t) (check (identifier? (rename 'value)) => #t) diff --git a/test/r7rs.ss b/test/r7rs.ss index f1c40ad0c..9f37a5305 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -356,7 +356,7 @@ (check (let ((x 'outer)) (let-syntax ((m ; (syntax-rules () ((m) x)) ; BUG - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) (list (rename 'quote) x))))) (let ((x 'inner)) @@ -368,7 +368,7 @@ ; ((my-or e1 e2 ...) ; (let ((temp e1)) ; (if temp temp (my-or e2 ...))))) - (%er-macro-transformer + (er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) From deea70e3bb7efa947c08bf17fe41bba5384532fa Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 6 Apr 2022 00:14:43 +0900 Subject: [PATCH 090/118] Update `hygienic-macro-transformer` not to include macro keywords in forms Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 27 ++++++++++++--------------- basis/r7rs.ss | 4 ++-- basis/srfi-39.ss | 2 +- basis/srfi-45.ss | 4 ++-- basis/srfi-78.ss | 2 +- basis/srfi-8.ss | 2 +- include/meevax/kernel/machine.hpp | 6 +++--- src/library/meevax.cpp | 2 +- test/er-macro-transformer.ss | 2 +- test/r7rs.ss | 2 +- 12 files changed, 29 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 123d1d089..a188f3d6b 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.916.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.917.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.916_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.917_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.916 +Meevax Lisp System, version 0.3.917 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f0ad0fd58..23ae381a6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.916 +0.3.917 diff --git a/basis/overture.ss b/basis/overture.ss index c0caf2606..3b4db500e 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -4,17 +4,14 @@ (define-syntax import (hygienic-macro-transformer - (lambda (import . import-sets) + (lambda import-sets (list quote (cons 'import import-sets))))) -(define (current-environment-specifier) - (hygienic-macro-transformer identity)) - (define (unspecified) (if #f #f)) (define-syntax cond (hygienic-macro-transformer - (lambda (cond . clauses) + (lambda clauses (if (null? clauses) (unspecified) ((lambda (clause) @@ -37,7 +34,7 @@ (define-syntax and (hygienic-macro-transformer - (lambda (and . tests) + (lambda tests (cond ((null? tests)) ((null? (cdr tests)) (car tests)) (else (list if (car tests) @@ -46,7 +43,7 @@ (define-syntax or (hygienic-macro-transformer - (lambda (or . tests) + (lambda tests (cond ((null? tests) #f) ((null? (cdr tests)) (car tests)) (else (list (list lambda (list result) @@ -79,7 +76,7 @@ (define-syntax quasiquote (hygienic-macro-transformer - (lambda (quasiquote template) + (lambda (template) (define (expand x depth) (cond ((pair? x) (cond ((free-identifier=? unquote (car x)) @@ -115,12 +112,12 @@ (define-syntax when (hygienic-macro-transformer - (lambda (when test . body) + (lambda (test . body) `(,if ,test (,begin ,@body))))) (define-syntax unless (hygienic-macro-transformer - (lambda (unless test . body) + (lambda (test . body) `(,if (,not ,test) (,begin ,@body))))) (define (map f x . xs) ; map-unorder @@ -187,7 +184,7 @@ (define-syntax let (hygienic-macro-transformer - (lambda (let bindings . body) + (lambda (bindings . body) (if (identifier? bindings) `(,letrec ((,bindings (,lambda ,(map car (car body)) ,@(cdr body)))) (,bindings ,@(map cadr (car body)))) @@ -195,7 +192,7 @@ (define-syntax let* (hygienic-macro-transformer - (lambda (let* bindings . body) + (lambda (bindings . body) (if (or (null? bindings) (null? (cdr bindings))) `(,let (,(car bindings)) ,@body) @@ -203,7 +200,7 @@ (define-syntax letrec* (hygienic-macro-transformer - (lambda (letrec* bindings . body) + (lambda (bindings . body) `(,let () ,@(map (lambda (x) (cons define x)) bindings) ,@body)))) (define (member o x . c) ; for case @@ -218,7 +215,7 @@ (define-syntax case (hygienic-macro-transformer - (lambda (case key . clauses) + (lambda (key . clauses) (define (body expressions) (cond ((null? expressions) result) ((free-identifier=? => (car expressions)) `(,(cadr expressions) ,result)) @@ -239,7 +236,7 @@ (define-syntax do (hygienic-macro-transformer - (lambda (do variables test . commands) + (lambda (variables test . commands) (let ((body `(,begin ,@commands (,rec ,@(map (lambda (x) (if (pair? (cddr x)) diff --git a/basis/r7rs.ss b/basis/r7rs.ss index 6fbce1fb2..6447696de 100644 --- a/basis/r7rs.ss +++ b/basis/r7rs.ss @@ -143,7 +143,7 @@ (define-syntax let-values (hygienic-macro-transformer - (lambda (let-values bindings . body) + (lambda (bindings . body) (if (null? bindings) (list let '() . body) (list call-with-values @@ -163,7 +163,7 @@ (define-syntax let*-values (hygienic-macro-transformer - (lambda (let*-values bindings . body) + (lambda (bindings . body) (if (null? bindings) (list let '() . body) (list let-values (list (car bindings)) diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index 44ff68f27..61fba9045 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -76,7 +76,7 @@ (define-syntax parameterize (hygienic-macro-transformer - (lambda (parameterize bindings . body) + (lambda (bindings . body) `(,dynamic-bind (,list ,@(map car bindings)) (,list ,@(map cadr bindings)) diff --git a/basis/srfi-45.ss b/basis/srfi-45.ss index e24bf7029..133d9e4b3 100644 --- a/basis/srfi-45.ss +++ b/basis/srfi-45.ss @@ -26,12 +26,12 @@ (define-syntax lazy (hygienic-macro-transformer - (lambda (lazy expression) + (lambda (expression) (list promise #f (list lambda '() expression))))) (define-syntax delay (hygienic-macro-transformer - (lambda (delay expression) + (lambda (expression) (list lazy (list promise #t expression))))) (define (make-promise x) diff --git a/basis/srfi-78.ss b/basis/srfi-78.ss index 489a7ad78..d7afa7491 100644 --- a/basis/srfi-78.ss +++ b/basis/srfi-78.ss @@ -179,7 +179,7 @@ (define-syntax check (hygienic-macro-transformer - (lambda (check expr rule expected) + (lambda (expr rule expected) (cond ((free-identifier=? => rule) `(,check ,expr (,=> ,equal?) ,expected)) ((free-identifier=? => (car rule)) diff --git a/basis/srfi-8.ss b/basis/srfi-8.ss index 6112aafc2..b9b9cf7c9 100644 --- a/basis/srfi-8.ss +++ b/basis/srfi-8.ss @@ -14,7 +14,7 @@ (define-syntax receive (hygienic-macro-transformer - (lambda (receive parameters expression . body) + (lambda (parameters expression . body) (define (list . xs) xs) (list call-with-values (list lambda '() expression) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 4458b36bc..fd17468b0 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -106,7 +106,7 @@ inline namespace kernel auto expand(const_reference form) -> object override { - return expander.apply(transform, form); + return expander.apply(transform, cdr(form)); } friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & @@ -214,7 +214,7 @@ inline namespace kernel return compile(context::none, current_environment, - notation.as().strip().as().expand(cons(notation.as().strip(), cdr(current_expression))), + notation.as().strip().as().expand(current_expression), current_syntactic_environment, current_continuation); } @@ -230,7 +230,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().expand(cons(applicant, cdr(current_expression))), + applicant.as().expand(current_expression), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index a789ab15b..3eeb6af9c 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2098,7 +2098,7 @@ namespace meevax { if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is_also()) { - return macro.as().expand(cons(macro, cdar(xs))); + return macro.as().expand(car(xs)); } else { diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index e54c78970..57a9ad1d5 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,6 +1,6 @@ (define-syntax swap! (hygienic-macro-transformer - (lambda (swap! a b) + (lambda (a b) `(,let ((,x ,a)) (,set! ,a ,b) (,set! ,b ,x))))) diff --git a/test/r7rs.ss b/test/r7rs.ss index 9f37a5305..d50457763 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -1195,7 +1195,7 @@ ; ---- 6.14. System interface -------------------------------------------------- -(check (eval '(+ 1 2 3) (current-environment-specifier)) => 6) +; TODO ; ------------------------------------------------------------------------------ From 923f256e3860741bf52e13159e8025036b0f2c5b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 10 Apr 2022 14:38:55 +0900 Subject: [PATCH 091/118] Remove struct `syntactic_closure` Signed-off-by: yamacir-kit --- README.md | 6 +-- VERSION | 2 +- include/meevax/kernel/environment.hpp | 14 +----- include/meevax/kernel/machine.hpp | 2 +- include/meevax/kernel/syntactic_closure.hpp | 56 --------------------- src/kernel/environment.cpp | 2 +- src/library/meevax.cpp | 14 +----- test/identifier.ss | 4 +- 8 files changed, 11 insertions(+), 89 deletions(-) delete mode 100644 include/meevax/kernel/syntactic_closure.hpp diff --git a/README.md b/README.md index a188f3d6b..e5054538f 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.917.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.919.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.917_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.919_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.917 +Meevax Lisp System, version 0.3.919 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 23ae381a6..9b678e821 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.917 +0.3.919 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 9242263b9..0cabe7e62 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -114,7 +114,7 @@ inline namespace kernel auto generate_free_identifier(const_reference x) -> object { - return make(reserve(x), e); + return x; // TODO } auto global_environment() noexcept -> reference; @@ -137,18 +137,6 @@ inline namespace kernel auto notate(const_reference, const_reference) -> object; auto notate(const_reference, const_reference) const -> object; - - template - auto rename(Ts&&... xs) - { - return make(notate(std::forward(xs)...), e); - } - - template - auto rename(Ts&&... xs) const - { - return make(notate(std::forward(xs)...), e); - } }; auto operator >>(std::istream &, environment &) -> std::istream &; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index fd17468b0..492897154 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -22,9 +22,9 @@ #include #include #include +#include #include #include -#include #include namespace meevax diff --git a/include/meevax/kernel/syntactic_closure.hpp b/include/meevax/kernel/syntactic_closure.hpp deleted file mode 100644 index bd8307ba4..000000000 --- a/include/meevax/kernel/syntactic_closure.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright 2018-2022 Tatsuya Yamasaki. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -#ifndef INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP -#define INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP - -#include - -namespace meevax -{ -inline namespace kernel -{ - struct syntactic_closure : public virtual pair // ( . e) - { - using pair::pair; - - auto symbol() const -> const_reference - { - assert(first.is_also()); - return first.as().symbol(); - } - - auto strip() - { - assert(first.is_also()); - return first.as().strip(second); - } - - auto is_bound() const -> bool - { - return not is_free(); - } - - auto is_free() const -> bool - { - assert(first.is_also()); - return first.is() and first.as().is_free(); - } - }; -} // namespace kernel -} // namespace meevax - -#endif // INCLUDED_MEEVAX_KERNEL_SYNTACTIC_CLOSURE_HPP diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index a67658a78..238537983 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -130,7 +130,7 @@ inline namespace kernel auto environment::is_identifier(const_reference x) -> bool { - return x.is() or x.is_also() or x.is(); + return x.is() or x.is_also(); } auto environment::load(std::string const& s) -> object diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 3eeb6af9c..f01784223 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1936,12 +1936,6 @@ namespace meevax return car(xs).is(); }); - define("identifier", [](let const& xs, let const& current_syntactic_environment, auto&& current_environment) - { - assert(car(xs).is()); - return current_environment.rename(car(xs), current_syntactic_environment); - }); - /* ------------------------------------------------------------------------- * * (identifier? syntax-object) procedure @@ -2037,11 +2031,7 @@ namespace meevax switch (length(xs)) { case 1: - if (let const& x = car(xs); x.is()) - { - return x.as().symbol(); - } - else if (x.is()) + if (let const& x = car(xs); x.is()) { return x; } @@ -2096,7 +2086,7 @@ namespace meevax define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) { - if (let const& macro = current_environment.rename(caar(xs), current_syntactic_environment).as().strip(); macro.is_also()) + if (let const& macro = current_environment.notate(caar(xs), current_syntactic_environment).as().strip(current_environment.e); macro.is_also()) { return macro.as().expand(car(xs)); } diff --git a/test/identifier.ss b/test/identifier.ss index 93087a725..72fcc2b6a 100644 --- a/test/identifier.ss +++ b/test/identifier.ss @@ -2,7 +2,7 @@ ; ------------------------------------------------------------------------------ -(check (identifier? (identifier 'value)) => #t) +; (check (identifier? (identifier 'value)) => #t) (check (identifier? 'value) => #t) @@ -10,7 +10,7 @@ ; ------------------------------------------------------------------------------ -(check (identifier->symbol (identifier 'value)) => value) +; (check (identifier->symbol (identifier 'value)) => value) (check-report) From 8b2fe26f1d1a281024b00a81b7116a58f6f42931 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 10 Apr 2022 14:52:56 +0900 Subject: [PATCH 092/118] Rename data member `transformer::transform` to `expression` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index e5054538f..4efca279b 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.919.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.920.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.919_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.920_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.919 +Meevax Lisp System, version 0.3.920 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9b678e821..750967818 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.919 +0.3.920 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 492897154..2e8185363 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -50,19 +50,19 @@ inline namespace kernel struct transformer { - let const transform; + let const expression; environment expander; - explicit transformer(const_reference transform, - const_reference current_syntactic_environment, + explicit transformer(const_reference expression, + const_reference syntactic_environment, environment const& current_environment) - : transform { transform } + : expression { expression } , expander { current_environment } { - assert(transform.is()); + assert(expression.is()); - expander.syntactic_environment() = current_syntactic_environment; + expander.syntactic_environment() = syntactic_environment; expander.reset(); } @@ -101,12 +101,12 @@ inline namespace kernel struct hygienic_macro_transformer : public transformer { using transformer::expander; + using transformer::expression; using transformer::transformer; - using transformer::transform; auto expand(const_reference form) -> object override { - return expander.apply(transform, cdr(form)); + return expander.apply(expression, cdr(form)); } friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & @@ -118,8 +118,8 @@ inline namespace kernel struct er_macro_transformer : public transformer { using transformer::expander; + using transformer::expression; using transformer::transformer; - using transformer::transform; auto expand(const_reference form) -> object override { @@ -134,7 +134,7 @@ inline namespace kernel return expander.is_same_free_identifier(car(xs), cadr(xs)); }); - return expander.apply(transform, list(form, rename, compare)); + return expander.apply(expression, list(form, rename, compare)); } friend auto operator <<(std::ostream & os, er_macro_transformer const& datum) -> std::ostream & From d6c219fcf4ce1cbdc42c08af1aca097e178abc76 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 11 Apr 2022 00:33:38 +0900 Subject: [PATCH 093/118] Rename syntax `define-syntax` to `%define-syntax` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 2 ++ src/library/meevax.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4efca279b..b9d35410d 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.920.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.921.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.920_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.921_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.920 +Meevax Lisp System, version 0.3.921 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 750967818..e68ca6602 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.920 +0.3.921 diff --git a/basis/overture.ss b/basis/overture.ss index 3b4db500e..9e5399d2e 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -2,6 +2,8 @@ (define (list . xs) xs) +(define define-syntax define) + (define-syntax import (hygienic-macro-transformer (lambda import-sets diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index f01784223..446bfd678 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -26,7 +26,7 @@ namespace meevax define("begin", machine::begin); define("call-with-current-continuation!", call_with_current_continuation); define("define", machine::define); - define("define-syntax", define_syntax); + define("%define-syntax", define_syntax); define("if", if_); define("lambda", lambda); define("let-syntax", let_syntax); From 01b79a71c6743ef7ea2c12040bedfa04c1148f54 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 11 Apr 2022 01:04:20 +0900 Subject: [PATCH 094/118] Update syntax `%define-syntax` to receive closure Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 32 +++++++++++++++++++++++++++++-- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b9d35410d..997116b89 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.921.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.922.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.921_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.922_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.921 +Meevax Lisp System, version 0.3.922 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index e68ca6602..b1d3f612b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.921 +0.3.922 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 2e8185363..6a2e94388 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -115,6 +115,23 @@ inline namespace kernel } }; + struct generic_macro_transformer : public transformer + { + using transformer::expander; + using transformer::expression; + using transformer::transformer; + + auto expand(const_reference form) -> object override + { + return expander.apply(expression, list(form, unit, unit)); + } + + friend auto operator <<(std::ostream & os, generic_macro_transformer const& datum) -> std::ostream & + { + return os << magenta("#,(") << green("generic-macro-transformer ") << faint("#;", &datum) << magenta(")"); + } + }; + struct er_macro_transformer : public transformer { using transformer::expander; @@ -393,7 +410,6 @@ inline namespace kernel d = cdr(d); goto decode; - case mnemonic::define_syntax: case mnemonic::define: /* ------------------------------------------------ * * (x' . s) e (%define . c) d => (x' . s) e c d @@ -405,6 +421,18 @@ inline namespace kernel c = cddr(c); goto decode; + case mnemonic::define_syntax: /* ----------------------------------------- + * + * ( . s) e (%define . c) d => (x' . s) e c d + * + * where = ( . x := ) + * + * ------------------------------------------------------------------- */ + assert(car(s).template is()); + cadr(c).template as().strip() = make(car(s), unit, static_cast(*this)); + c = cddr(c); + goto decode; + case mnemonic::let_syntax: /* -------------------------------------------- * * s e (%let_syntax . c) d => s e c' d @@ -446,7 +474,7 @@ inline namespace kernel { env.execute(compile(context::outermost, env, - cons(make("define-syntax", define_syntax), transformer_spec), + cons(make("define-syntax", define), transformer_spec), cadr(c).template as().syntactic_environment())); } From bfc41d5708eb3f55b37cd4d9ad01c36975b87105 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 11 Apr 2022 01:28:24 +0900 Subject: [PATCH 095/118] Update `transformer::expand` to receive current syntactic-environment Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 14 +++++++------- src/library/meevax.cpp | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 997116b89..a20a6bd84 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.922.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.923.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.922_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.923_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.922 +Meevax Lisp System, version 0.3.923 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index b1d3f612b..1400664b0 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.922 +0.3.923 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 6a2e94388..5861f6031 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -66,7 +66,7 @@ inline namespace kernel expander.reset(); } - virtual auto expand(const_reference) -> object = 0; /* ------------------- + virtual auto expand(const_reference, const_reference) -> object = 0; /* -- * * Scheme programs can define and use new derived expression types, * called macros. Program-defined expression types have the syntax @@ -104,7 +104,7 @@ inline namespace kernel using transformer::expression; using transformer::transformer; - auto expand(const_reference form) -> object override + auto expand(const_reference form, const_reference) -> object override { return expander.apply(expression, cdr(form)); } @@ -121,9 +121,9 @@ inline namespace kernel using transformer::expression; using transformer::transformer; - auto expand(const_reference form) -> object override + auto expand(const_reference form, const_reference current_syntactic_environment) -> object override { - return expander.apply(expression, list(form, unit, unit)); + return expander.apply(expression, list(form, current_syntactic_environment, expander.syntactic_environment())); } friend auto operator <<(std::ostream & os, generic_macro_transformer const& datum) -> std::ostream & @@ -138,7 +138,7 @@ inline namespace kernel using transformer::expression; using transformer::transformer; - auto expand(const_reference form) -> object override + auto expand(const_reference form, const_reference) -> object override { auto rename = make("rename", [](let const& xs, auto&&, auto&& expander) { @@ -231,7 +231,7 @@ inline namespace kernel return compile(context::none, current_environment, - notation.as().strip().as().expand(current_expression), + notation.as().strip().as().expand(current_expression, current_syntactic_environment), current_syntactic_environment, current_continuation); } @@ -247,7 +247,7 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().expand(current_expression), + applicant.as().expand(current_expression, current_syntactic_environment), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 446bfd678..732d6d485 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2088,7 +2088,7 @@ namespace meevax { if (let const& macro = current_environment.notate(caar(xs), current_syntactic_environment).as().strip(current_environment.e); macro.is_also()) { - return macro.as().expand(car(xs)); + return macro.as().expand(car(xs), current_syntactic_environment); } else { From a1dab847f05be9ee6d7f1ec7f3dc80f32d3de2ff Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 13 Apr 2022 00:36:54 +0900 Subject: [PATCH 096/118] Add new member function `environment::fork` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 7 +++++++ include/meevax/kernel/machine.hpp | 6 ++++-- src/library/meevax.cpp | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index a20a6bd84..290325a29 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.923.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.924.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.923_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.924_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.923 +Meevax Lisp System, version 0.3.924 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1400664b0..557b6e7e6 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.923 +0.3.924 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 0cabe7e62..493aa1078 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -79,6 +79,13 @@ inline namespace kernel auto execute(const_reference) -> object; + auto fork(const_reference syntactic_environment) + { + let const copy = make(*this); + copy.as().syntactic_environment() = syntactic_environment; + return copy; + } + auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool { let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 5861f6031..773a7e978 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -231,7 +231,8 @@ inline namespace kernel return compile(context::none, current_environment, - notation.as().strip().as().expand(current_expression, current_syntactic_environment), + notation.as().strip().as().expand(current_expression, + current_environment.fork(current_syntactic_environment)), current_syntactic_environment, current_continuation); } @@ -247,7 +248,8 @@ inline namespace kernel { return compile(context::none, current_environment, - applicant.as().expand(current_expression, current_syntactic_environment), + applicant.as().expand(current_expression, + current_environment.fork(current_syntactic_environment)), current_syntactic_environment, current_continuation); } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 732d6d485..1b0cecf79 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2088,7 +2088,7 @@ namespace meevax { if (let const& macro = current_environment.notate(caar(xs), current_syntactic_environment).as().strip(current_environment.e); macro.is_also()) { - return macro.as().expand(car(xs), current_syntactic_environment); + return macro.as().expand(car(xs), current_environment.fork(current_syntactic_environment)); } else { From e0a8beb82c25664f51c38ebcf5be1bfa3f2e5e4f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 13 Apr 2022 01:24:52 +0900 Subject: [PATCH 097/118] Update `transformer`'s constructor to receive forked environment Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 2 +- include/meevax/kernel/machine.hpp | 27 +++++++++++---------------- src/library/meevax.cpp | 17 ++++++++++++++--- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 290325a29..1cf214b84 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.924.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.925.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.924_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.925_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.924 +Meevax Lisp System, version 0.3.925 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 557b6e7e6..6bcbfe337 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.924 +0.3.925 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 493aa1078..da3b777fc 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -79,7 +79,7 @@ inline namespace kernel auto execute(const_reference) -> object; - auto fork(const_reference syntactic_environment) + auto fork(const_reference syntactic_environment) const { let const copy = make(*this); copy.as().syntactic_environment() = syntactic_environment; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 773a7e978..2dfefadce 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -52,18 +52,13 @@ inline namespace kernel { let const expression; - environment expander; + let const mac_env; - explicit transformer(const_reference expression, - const_reference syntactic_environment, - environment const& current_environment) + explicit transformer(const_reference expression, const_reference mac_env) : expression { expression } - , expander { current_environment } + , mac_env { mac_env } { assert(expression.is()); - - expander.syntactic_environment() = syntactic_environment; - expander.reset(); } virtual auto expand(const_reference, const_reference) -> object = 0; /* -- @@ -100,13 +95,13 @@ inline namespace kernel struct hygienic_macro_transformer : public transformer { - using transformer::expander; using transformer::expression; + using transformer::mac_env; using transformer::transformer; auto expand(const_reference form, const_reference) -> object override { - return expander.apply(expression, cdr(form)); + return mac_env.template as().apply(expression, cdr(form)); } friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & @@ -117,13 +112,13 @@ inline namespace kernel struct generic_macro_transformer : public transformer { - using transformer::expander; using transformer::expression; + using transformer::mac_env; using transformer::transformer; - auto expand(const_reference form, const_reference current_syntactic_environment) -> object override + auto expand(const_reference form, const_reference use_env) -> object override { - return expander.apply(expression, list(form, current_syntactic_environment, expander.syntactic_environment())); + return mac_env.template as().apply(expression, list(form, use_env, mac_env)); } friend auto operator <<(std::ostream & os, generic_macro_transformer const& datum) -> std::ostream & @@ -134,8 +129,8 @@ inline namespace kernel struct er_macro_transformer : public transformer { - using transformer::expander; using transformer::expression; + using transformer::mac_env; using transformer::transformer; auto expand(const_reference form, const_reference) -> object override @@ -151,7 +146,7 @@ inline namespace kernel return expander.is_same_free_identifier(car(xs), cadr(xs)); }); - return expander.apply(expression, list(form, rename, compare)); + return mac_env.template as().apply(expression, list(form, rename, compare)); } friend auto operator <<(std::ostream & os, er_macro_transformer const& datum) -> std::ostream & @@ -431,7 +426,7 @@ inline namespace kernel * * ------------------------------------------------------------------- */ assert(car(s).template is()); - cadr(c).template as().strip() = make(car(s), unit, static_cast(*this)); + cadr(c).template as().strip() = make(car(s), static_cast(*this).fork(unit)); c = cddr(c); goto decode; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 1b0cecf79..5b5097d27 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1671,7 +1671,7 @@ namespace meevax define("eval", [](let const& xs, auto&&...) { - return cadr(xs).as().expander.evaluate(car(xs)); // DIRTY HACK! + return cadr(xs).as().mac_env.as().evaluate(car(xs)); // DIRTY HACK! }); } @@ -1923,12 +1923,23 @@ namespace meevax { define("hygienic-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { - return make(car(xs), current_syntactic_environment, current_environment); + return make(car(xs), current_environment.fork(current_syntactic_environment)); + }); + + define("make-syntactic-closure", [](let const& xs, auto&&...) + { + // PRINT(car(xs)); // syntactic-environment + // PRINT(cadr(xs)); // free-variables + // PRINT(caddr(xs)); // expression + // + // return make(environment, car(xs), cadr(xs), caddr(xs)); + + return caddr(xs); }); define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { - return make(car(xs), current_syntactic_environment, current_environment); + return make(car(xs), current_environment.fork(current_syntactic_environment)); }); define("er-macro-transformer?", [](let const& xs, auto&&...) From 96a46f9b8ed4a7e64a6b5758697a0e5d5f9d110b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 16 Apr 2022 00:58:28 +0900 Subject: [PATCH 098/118] Support `syntactic_closure` (experimental) Signed-off-by: yamacir-kit --- CMakeLists.txt | 1 + README.md | 6 +- VERSION | 2 +- include/meevax/kernel/machine.hpp | 37 ++++++++++- src/kernel/environment.cpp | 2 +- src/library/meevax.cpp | 8 +-- test/transformer.ss | 101 ++++++++++++++++++++++++++++++ 7 files changed, 144 insertions(+), 13 deletions(-) create mode 100644 test/transformer.ss diff --git a/CMakeLists.txt b/CMakeLists.txt index dafcd539f..085e9d4a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -178,6 +178,7 @@ check(r5rs) check(r7rs) check(sicp-1) check(srfi-8) +check(transformer) file(GLOB ${PROJECT_NAME}_TEST_CXX ${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp) foreach(FILEPATH IN LISTS ${PROJECT_NAME}_TEST_CXX) diff --git a/README.md b/README.md index 1cf214b84..e2a8e212e 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.925.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.926.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.925_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.926_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.925 +Meevax Lisp System, version 0.3.926 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 6bcbfe337..1f01f615d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.925 +0.3.926 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 2dfefadce..6e248ac85 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -127,6 +127,25 @@ inline namespace kernel } }; + struct syntactic_closure + { + let const enclosure; + + let const free_variables; + + let const expression; + + auto notate() + { + return enclosure.as().notate(expression, enclosure.as().syntactic_environment()); + } + + friend auto operator <<(std::ostream & os, syntactic_closure const& datum) -> std::ostream & + { + return os << magenta("#,(") << blue("make-syntactic-closure ") << datum.enclosure << " " << magenta("'") << datum.free_variables << " " << magenta("'") << datum.expression << magenta(")"); + } + }; + struct er_macro_transformer : public transformer { using transformer::expression; @@ -214,6 +233,22 @@ inline namespace kernel return cons(n.as().make_load_instruction(), n, current_continuation); } + else if (current_expression.is()) + { + if (let const& n = std::as_const(current_environment).notate(current_expression, current_syntactic_environment); select(n)) + { + return cons(n.as().make_load_instruction(), n, + current_continuation); + } + else + { + return compile(current_context, + current_expression.as().enclosure.template as(), + current_expression.as().expression, + current_expression.as().enclosure.template as().syntactic_environment(), + current_continuation); + } + } else // is { return cons(make(mnemonic::load_constant), current_expression, @@ -689,7 +724,7 @@ inline namespace kernel } } - return f; + return variable.is() ? variable.as().notate() : f; } inline auto reset() -> void diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 238537983..a67658a78 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -130,7 +130,7 @@ inline namespace kernel auto environment::is_identifier(const_reference x) -> bool { - return x.is() or x.is_also(); + return x.is() or x.is_also() or x.is(); } auto environment::load(std::string const& s) -> object diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 5b5097d27..adafeeef5 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1928,13 +1928,7 @@ namespace meevax define("make-syntactic-closure", [](let const& xs, auto&&...) { - // PRINT(car(xs)); // syntactic-environment - // PRINT(cadr(xs)); // free-variables - // PRINT(caddr(xs)); // expression - // - // return make(environment, car(xs), cadr(xs), caddr(xs)); - - return caddr(xs); + return make(car(xs), cadr(xs), caddr(xs)); }); define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) diff --git a/test/transformer.ss b/test/transformer.ss new file mode 100644 index 000000000..07d6907a9 --- /dev/null +++ b/test/transformer.ss @@ -0,0 +1,101 @@ +(define (simple-macro-transformer f) + (lambda (form use-env mac-env) + (apply f (cdr form)))) + +(%define-syntax swap! + (simple-macro-transformer + (lambda (a b) + `(let ((value ,a)) + (set! ,a ,b) + (set! ,b value))))) + +(check (transformer? swap!) => #t) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +; (print (macroexpand-1 '(swap! x y))) + +(swap! x y) + +(check (cons x y) => (2 . 1)) + +; ; ------------------------------------------------------------------------------ + +(define (sc-macro-transformer f) + (lambda (form use-env mac-env) + (make-syntactic-closure mac-env '() (f form use-env)))) + +(%define-syntax swap! + (sc-macro-transformer + (lambda (form use-env) + (let ((a (make-syntactic-closure use-env '() (cadr form))) + (b (make-syntactic-closure use-env '() (caddr form)))) + `(let ((value ,a)) + (set! ,a ,b) + (set! ,b value)))))) + +(check (transformer? swap!) => #t) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +; (print (macroexpand-1 '(swap! x y))) + +(let ((a 'non-hygienic!) + (b 'non-hygienic!) + (let 'non-hygienic!) + (set! 'non-hygienic!) + (value 'non-hygienic!)) + (swap! x y)) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ + +(define (rsc-macro-transformer f) + (lambda (form use-env mac-env) + (make-syntactic-closure use-env '() (f form mac-env)))) + +(%define-syntax swap! + (rsc-macro-transformer + (lambda (form mac-env) + (let ((a (cadr form)) + (b (caddr form)) + (LET (make-syntactic-closure mac-env '() 'let)) + (VALUE (make-syntactic-closure mac-env '() 'value)) + (SET! (make-syntactic-closure mac-env '() 'set!))) + `(,LET ((,VALUE ,a)) + (,SET! ,a ,b) + (,SET! ,b ,VALUE)))))) + +(check (transformer? swap!) => #t) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +; (print (macroexpand-1 '(swap! x y))) + +(let ((a 'non-hygienic!) + (b 'non-hygienic!) + (let 'non-hygienic!) + (set! 'non-hygienic!) + (value 'non-hygienic!)) + (swap! x y)) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ + +(check-report) + +(exit (check-passed? check:correct)) From 63da796e584591391cd26b442d6e7393856a7a46 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 16 Apr 2022 01:58:51 +0900 Subject: [PATCH 099/118] Add new procedure `experimental:er-macro-transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 27 ++++++++++++++++++++------- src/library/meevax.cpp | 2 +- test/transformer.ss | 39 ++++++++++++++++++++++++++++++++++++--- 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e2a8e212e..be81ca170 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.926.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.927.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.926_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.927_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.926 +Meevax Lisp System, version 0.3.927 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1f01f615d..520b8d6c1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.926 +0.3.927 diff --git a/basis/overture.ss b/basis/overture.ss index 9e5399d2e..83551a738 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -11,6 +11,16 @@ (define (unspecified) (if #f #f)) +(define (experimental:er-macro-transformer f) + (lambda (form use-env mac-env) + (define (rename x) + (make-syntactic-closure mac-env '() x)) + (define (compare x y) + (define (identifier=? e1 x e2 y) + (eqv? x y)) + (identifier=? use-env x use-env y)) + (f form rename compare))) + (define-syntax cond (hygienic-macro-transformer (lambda clauses @@ -34,13 +44,16 @@ (cons cond (cdr clauses)))))) (car clauses)))))) -(define-syntax and - (hygienic-macro-transformer - (lambda tests - (cond ((null? tests)) - ((null? (cdr tests)) (car tests)) - (else (list if (car tests) - (cons and (cdr tests)) +(experimental:define-syntax and + (experimental:er-macro-transformer + (lambda (form rename compare) + (cond ((null? (cdr form))) + ((null? (cddr form)) + (cadr form)) + (else (list (rename 'if) + (cadr form) + (cons (rename 'and) + (cddr form)) #f)))))) (define-syntax or diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index adafeeef5..f2c96f375 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -26,7 +26,7 @@ namespace meevax define("begin", machine::begin); define("call-with-current-continuation!", call_with_current_continuation); define("define", machine::define); - define("%define-syntax", define_syntax); + define("experimental:define-syntax", define_syntax); define("if", if_); define("lambda", lambda); define("let-syntax", let_syntax); diff --git a/test/transformer.ss b/test/transformer.ss index 07d6907a9..8e1782530 100644 --- a/test/transformer.ss +++ b/test/transformer.ss @@ -2,7 +2,7 @@ (lambda (form use-env mac-env) (apply f (cdr form)))) -(%define-syntax swap! +(experimental:define-syntax swap! (simple-macro-transformer (lambda (a b) `(let ((value ,a)) @@ -29,7 +29,7 @@ (lambda (form use-env mac-env) (make-syntactic-closure mac-env '() (f form use-env)))) -(%define-syntax swap! +(experimental:define-syntax swap! (sc-macro-transformer (lambda (form use-env) (let ((a (make-syntactic-closure use-env '() (cadr form))) @@ -63,7 +63,7 @@ (lambda (form use-env mac-env) (make-syntactic-closure use-env '() (f form mac-env)))) -(%define-syntax swap! +(experimental:define-syntax swap! (rsc-macro-transformer (lambda (form mac-env) (let ((a (cadr form)) @@ -96,6 +96,39 @@ ; ------------------------------------------------------------------------------ +(experimental:define-syntax swap! + (experimental:er-macro-transformer + (lambda (form rename compare?) + (let ((a (cadr form)) + (b (caddr form)) + (LET (rename 'let)) + (VALUE (rename 'value)) + (SET! (rename 'set!))) + `(,LET ((,VALUE ,a)) + (,SET! ,a ,b) + (,SET! ,b ,VALUE)))))) + +(check (transformer? swap!) => #t) + +(define x 1) + +(define y 2) + +(check (cons x y) => (1 . 2)) + +; (print (macroexpand-1 '(swap! x y))) + +(let ((a 'non-hygienic!) + (b 'non-hygienic!) + (let 'non-hygienic!) + (set! 'non-hygienic!) + (value 'non-hygienic!)) + (swap! x y)) + +(check (cons x y) => (2 . 1)) + +; ------------------------------------------------------------------------------ + (check-report) (exit (check-passed? check:correct)) From ffd0c4a95f8520c8207acdab201228d7a7a5d1bc Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 16 Apr 2022 15:03:00 +0900 Subject: [PATCH 100/118] Rewrite some syntaxes with `experimental:er-macro-transformer` Signed-off-by: yamacir-kit --- CMakeLists.txt | 1 - README.md | 6 +- VERSION | 2 +- basis/overture.ss | 96 ++++++++++++++++++++------------ basis/r7rs.ss | 34 +++++------ basis/srfi-39.ss | 14 ++--- basis/srfi-45.ss | 18 +++--- basis/srfi-78.ss | 17 +++--- basis/srfi-8.ss | 20 ++----- test/abandoned.ss | 17 +----- test/er-macro-transformer.ss | 4 +- test/low-level-macro-facility.ss | 48 ---------------- test/transformer.ss | 14 +---- 13 files changed, 121 insertions(+), 170 deletions(-) delete mode 100644 test/low-level-macro-facility.ss diff --git a/CMakeLists.txt b/CMakeLists.txt index 085e9d4a1..32eeb1563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,7 +170,6 @@ check(identifier) check(internal-definition) check(let-syntax) check(letrec-syntax) -check(low-level-macro-facility) check(numerical-operations) check(r4rs) check(r4rs-appendix) diff --git a/README.md b/README.md index be81ca170..8df3d5eae 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.927.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.928.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.927_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.928_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.927 +Meevax Lisp System, version 0.3.928 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 520b8d6c1..0f2739309 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.927 +0.3.928 diff --git a/basis/overture.ss b/basis/overture.ss index 83551a738..9242fa5f9 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -2,14 +2,21 @@ (define (list . xs) xs) -(define define-syntax define) +(define (unspecified) (if #f #f)) -(define-syntax import - (hygienic-macro-transformer - (lambda import-sets - (list quote (cons 'import import-sets))))) +; ------------------------------------------------------------------------------ -(define (unspecified) (if #f #f)) +(define (traditional-macro-transformer f) + (lambda (form use-env mac-env) + (apply f (cdr form)))) + +(define (sc-macro-transformer f) + (lambda (form use-env mac-env) + (make-syntactic-closure mac-env '() (f form use-env)))) + +(define (rsc-macro-transformer f) + (lambda (form use-env mac-env) + (make-syntactic-closure use-env '() (f form mac-env)))) (define (experimental:er-macro-transformer f) (lambda (form use-env mac-env) @@ -21,6 +28,15 @@ (identifier=? use-env x use-env y)) (f form rename compare))) +(define define-syntax define) + +(experimental:define-syntax import + (experimental:er-macro-transformer + (lambda (form rename compare) + (list (rename 'quote) (cons 'import (cdr form)))))) + +; ------------------------------------------------------------------------------ + (define-syntax cond (hygienic-macro-transformer (lambda clauses @@ -56,16 +72,21 @@ (cddr form)) #f)))))) -(define-syntax or - (hygienic-macro-transformer - (lambda tests - (cond ((null? tests) #f) - ((null? (cdr tests)) (car tests)) - (else (list (list lambda (list result) - (list if result - result - (cons or (cdr tests)))) - (car tests))))))) +(experimental:define-syntax or + (experimental:er-macro-transformer + (lambda (form rename compare) + (define RESULT (rename 'result)) + (cond ((null? (cdr form)) #f) + ((null? (cddr form)) + (cadr form)) + (else (list (list (rename 'lambda) + (list RESULT) + (list (rename 'if) + RESULT + RESULT + (cons (rename 'or) + (cddr form)))) + (cadr form))))))) (define (append-2 x y) (if (null? x) y @@ -125,15 +146,17 @@ (define (not x) (if x #f #t)) -(define-syntax when - (hygienic-macro-transformer - (lambda (test . body) - `(,if ,test (,begin ,@body))))) +(experimental:define-syntax when + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'if) ,(cadr form) + (,(rename 'begin) ,@(cddr form)))))) -(define-syntax unless - (hygienic-macro-transformer - (lambda (test . body) - `(,if (,not ,test) (,begin ,@body))))) +(experimental:define-syntax unless + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'if) (,(rename 'not) ,(cadr form)) + (,(rename 'begin) ,@(cddr form)))))) (define (map f x . xs) ; map-unorder (define (map-1 f x xs) @@ -205,18 +228,21 @@ (,bindings ,@(map cadr (car body)))) `((,lambda ,(map car bindings) ,@body) ,@(map cadr bindings)))))) -(define-syntax let* - (hygienic-macro-transformer - (lambda (bindings . body) - (if (or (null? bindings) - (null? (cdr bindings))) - `(,let (,(car bindings)) ,@body) - `(,let (,(car bindings)) (,let* ,(cdr bindings) ,@body)))))) +(experimental:define-syntax let* + (experimental:er-macro-transformer + (lambda (form rename compare) + (if (null? (cadr form)) + `(,(rename 'let) () ,@(cddr form)) + `(,(rename 'let) (,(caadr form)) + (,(rename 'let*) ,(cdadr form) + ,@(cddr form))))))) -(define-syntax letrec* - (hygienic-macro-transformer - (lambda (bindings . body) - `(,let () ,@(map (lambda (x) (cons define x)) bindings) ,@body)))) +(experimental:define-syntax letrec* + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'let) ,@(map (lambda (x) (cons (rename 'define) x)) + (cadr form)) + ,@(cddr form))))) (define (member o x . c) ; for case (let ((compare (if (pair? c) (car c) equal?))) diff --git a/basis/r7rs.ss b/basis/r7rs.ss index 6447696de..8cb6d0aca 100644 --- a/basis/r7rs.ss +++ b/basis/r7rs.ss @@ -141,15 +141,16 @@ ; (let-values "bind" ; bindings (tmp ... (a x)) body)))))) -(define-syntax let-values - (hygienic-macro-transformer - (lambda (bindings . body) - (if (null? bindings) - (list let '() . body) - (list call-with-values - (list lambda () (cadar bindings)) - (list lambda (caar bindings) - (list let-values (cdr bindings) . body))))))) +(experimental:define-syntax let-values + (experimental:er-macro-transformer + (lambda (form rename compare) + (if (null? (cadr form)) + `(,(rename 'let) () ,@(cddr form)) + `(,(rename 'call-with-values) + (,(rename 'lambda) () ,(cadar (cadr form))) + (,(rename 'lambda) ,(caar (cadr form)) + (,(rename 'let-values) ,(cdr (cadr form)) + ,@(cddr form)))))))) ; (define-syntax let*-values ; (syntax-rules () @@ -161,13 +162,14 @@ ; (let*-values (binding1 ...) ; body0 body1 ...))))) -(define-syntax let*-values - (hygienic-macro-transformer - (lambda (bindings . body) - (if (null? bindings) - (list let '() . body) - (list let-values (list (car bindings)) - (list let*-values (cdr bindings) . body)))))) +(experimental:define-syntax let*-values + (experimental:er-macro-transformer + (lambda (form rename compare) + (if (null? (cadr form)) + `(,(rename 'let) () ,@(cddr form)) + `(,(rename 'let-values) (,(caadr form)) + (,(rename 'let*-values) ,(cdadr form) + ,@(cddr form))))))) ; ---- 4.2.3. Sequencing ------------------------------------------------------- diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index 61fba9045..bbf94fa7a 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -74,10 +74,10 @@ ; (list ,@(map cadr bindings)) ; (lambda () ,@body)))))) -(define-syntax parameterize - (hygienic-macro-transformer - (lambda (bindings . body) - `(,dynamic-bind - (,list ,@(map car bindings)) - (,list ,@(map cadr bindings)) - (,lambda () ,@body))))) +(experimental:define-syntax parameterize + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'dynamic-bind) (,(rename 'list) ,@(map car (cadr form))) + (,(rename 'list) ,@(map cadr (cadr form))) + (,(rename 'lambda) () ,@(cddr form)))))) + diff --git a/basis/srfi-45.ss b/basis/srfi-45.ss index 133d9e4b3..f42d4eab7 100644 --- a/basis/srfi-45.ss +++ b/basis/srfi-45.ss @@ -24,15 +24,15 @@ (promise-merge! new promise)) (force promise)))) -(define-syntax lazy - (hygienic-macro-transformer - (lambda (expression) - (list promise #f (list lambda '() expression))))) - -(define-syntax delay - (hygienic-macro-transformer - (lambda (expression) - (list lazy (list promise #t expression))))) +(experimental:define-syntax lazy + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'promise) #f (,(rename 'lambda) () ,(cadr form)))))) + +(experimental:define-syntax delay + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'lazy) (,(rename 'promise) #t ,(cadr form)))))) (define (make-promise x) (if (promise? x) x diff --git a/basis/srfi-78.ss b/basis/srfi-78.ss index d7afa7491..b6448939d 100644 --- a/basis/srfi-78.ss +++ b/basis/srfi-78.ss @@ -177,14 +177,17 @@ ; (if (>= check:mode 1) ; (check:proc 'expr (lambda () expr) equal expected))))) -(define-syntax check - (hygienic-macro-transformer - (lambda (expr rule expected) - (cond ((free-identifier=? => rule) - `(,check ,expr (,=> ,equal?) ,expected)) - ((free-identifier=? => (car rule)) +(experimental:define-syntax check + (experimental:er-macro-transformer + (lambda (form rename compare) + (cond ((free-identifier=? => (caddr form)) + `(,(rename 'check) ,(cadr form) (,=> ,(rename 'equal?)) ,(cadddr form))) + ((free-identifier=? => (caaddr form)) (if (<= 1 check:mode) - `(,check:proc ',expr (,lambda () ,expr) ,(cadr rule) ',expected))) + `(,(rename 'check:proc) ',(cadr form) + (,(rename 'lambda) () ,(cadr form)) + ,(cadr (caddr form)) + ',(cadddr form)))) (else (unspecified)))))) ; -- parametric checks -- diff --git a/basis/srfi-8.ss b/basis/srfi-8.ss index b9b9cf7c9..36ca0a621 100644 --- a/basis/srfi-8.ss +++ b/basis/srfi-8.ss @@ -5,17 +5,9 @@ ; (lambda () expression) ; (lambda parameters . body))))) -; (define-syntax receive -; (er-macro-transformer -; (lambda (form rename compare) -; `(call-with-values -; (,(rename 'lambda) () ,(caddr form)) -; (,(rename 'lambda) ,(cadr form) ,@(cdddr form)))))) - -(define-syntax receive - (hygienic-macro-transformer - (lambda (parameters expression . body) - (define (list . xs) xs) - (list call-with-values - (list lambda '() expression) - (list lambda parameters . body))))) +(experimental:define-syntax receive + (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename 'call-with-values) + (,(rename 'lambda) () ,(caddr form)) + (,(rename 'lambda) ,(cadr form) ,@(cdddr form)))))) diff --git a/test/abandoned.ss b/test/abandoned.ss index c80005009..37eb52218 100644 --- a/test/abandoned.ss +++ b/test/abandoned.ss @@ -71,14 +71,12 @@ (let ((s "abcde")) (check (begin (string-fill! s #\x 1) s) => "axxxx")) (let ((s "abcde")) (check (begin (string-fill! s #\x 1 4) s) => "axxxe")) -(define-syntax loop - (er-macro-transformer +(experimental:define-syntax loop + (experimental:er-macro-transformer (lambda (form rename compare) `(,(rename 'call/cc) (,(rename 'lambda) (exit) - (,(rename 'let) ,(rename 'rec) () - ,(cadr form) - (,(rename 'rec)))))))) + (,(rename 'let) ,(rename 'rec) () ,(cadr form) (,(rename 'rec)))))))) (define f (lambda () @@ -98,15 +96,6 @@ (begin (display x) (set! x (+ x 1)) ))))) -; (define-syntax loop -; (non-hygienic-macro-transformer -; (lambda (form) -; `(call-with-current-continuation -; (lambda (exit) -; (let loop () -; ,form -; (loop))))))) - ; (define-syntax loop ; (sc-macro-transformer ; (lambda (form environment) diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index 57a9ad1d5..c5f5a82f7 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -1,5 +1,5 @@ -(define-syntax swap! - (hygienic-macro-transformer +(experimental:define-syntax swap! + (traditional-macro-transformer (lambda (a b) `(,let ((,x ,a)) (,set! ,a ,b) diff --git a/test/low-level-macro-facility.ss b/test/low-level-macro-facility.ss deleted file mode 100644 index d38125ad6..000000000 --- a/test/low-level-macro-facility.ss +++ /dev/null @@ -1,48 +0,0 @@ -(define x 42) - -(check x => 42) - -; (define hygienic-x (syntax x)) - -(define rename - (let ((e (hygienic-macro-transformer list))) - (lambda (x) - (eval x e)))) - -(let ((x 3.14)) - (check x => 3.14) - ; (check hygienic-x => 42) - (check (rename 'x) => 42)) - -; (define-syntax (swap! x y) -; `(,let ((,value ,x)) -; (,set! ,x ,y) -; (,set! ,y ,value))) - -(define-syntax swap! - (er-macro-transformer - (lambda (form rename compare) - (check (transformer? (rename 'let)) => #t) - (check (identifier? (rename 'value)) => #t) - (let ((a (cadr form)) - (b (caddr form))) - `(,(rename 'let) ((,(rename 'value) ,a)) - (,(rename 'set!) ,a ,b) - (,(rename 'set!) ,b ,(rename 'value))))))) - -(check (let ((x 1) - (y 2)) - (swap! x y) - (cons x y)) => (2 . 1)) - -(check (let ((x 1) - (y 2) - (let '()) - (set! '()) - (value 42)) - (swap! x y) - (cons x y)) => (2 . 1)) - -(check-report) - -(exit (check-passed? check:correct)) diff --git a/test/transformer.ss b/test/transformer.ss index 8e1782530..0c56b2cf4 100644 --- a/test/transformer.ss +++ b/test/transformer.ss @@ -1,9 +1,5 @@ -(define (simple-macro-transformer f) - (lambda (form use-env mac-env) - (apply f (cdr form)))) - (experimental:define-syntax swap! - (simple-macro-transformer + (traditional-macro-transformer (lambda (a b) `(let ((value ,a)) (set! ,a ,b) @@ -25,10 +21,6 @@ ; ; ------------------------------------------------------------------------------ -(define (sc-macro-transformer f) - (lambda (form use-env mac-env) - (make-syntactic-closure mac-env '() (f form use-env)))) - (experimental:define-syntax swap! (sc-macro-transformer (lambda (form use-env) @@ -59,10 +51,6 @@ ; ------------------------------------------------------------------------------ -(define (rsc-macro-transformer f) - (lambda (form use-env mac-env) - (make-syntactic-closure use-env '() (f form mac-env)))) - (experimental:define-syntax swap! (rsc-macro-transformer (lambda (form mac-env) From 2f9c3f3548865235fca284c19aec0c3a4c1b5469 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 20 Apr 2022 00:33:28 +0900 Subject: [PATCH 101/118] Rewrite all derived expression types with `experimental:er-macro-transformer` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- basis/overture.ss | 164 +++++++++++++++++++++++------------------ src/library/meevax.cpp | 28 +++++++ test/identifier.ss | 44 ++++++++++- 5 files changed, 167 insertions(+), 77 deletions(-) diff --git a/README.md b/README.md index 8df3d5eae..706467cf0 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.928.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.929.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.928_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.929_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.928 +Meevax Lisp System, version 0.3.929 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 0f2739309..ed2dc7a03 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.928 +0.3.929 diff --git a/basis/overture.ss b/basis/overture.ss index 9242fa5f9..d52caedb3 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -37,28 +37,31 @@ ; ------------------------------------------------------------------------------ -(define-syntax cond - (hygienic-macro-transformer - (lambda clauses - (if (null? clauses) +(experimental:define-syntax cond + (experimental:er-macro-transformer + (lambda (form rename compare) + (if (null? (cdr form)) (unspecified) ((lambda (clause) (if (free-identifier=? else (car clause)) - (if (pair? (cdr clauses)) - (error "else clause must be at the end of cond clause" clauses) - (cons begin (cdr clause))) + (cons (rename 'begin) (cdr clause)) (if (if (null? (cdr clause)) #t (free-identifier=? => (cadr clause))) - (list (list lambda (list result) - (list if result - (if (null? (cdr clause)) result - (list (car (cddr clause)) result)) - (cons cond (cdr clauses)))) + (list (list (rename 'lambda) + (list result) + (list (rename 'if) + result + (if (null? (cdr clause)) + result + (list (caddr clause) + result)) + (cons (rename 'cond) (cddr form)))) (car clause)) - (list if (car clause) - (cons begin (cdr clause)) - (cons cond (cdr clauses)))))) - (car clauses)))))) + (list (rename 'if) + (car clause) + (cons (rename 'begin) (cdr clause)) + (cons (rename 'cond) (cddr form)))))) + (cadr form)))))) (experimental:define-syntax and (experimental:er-macro-transformer @@ -110,39 +113,48 @@ (car xs))) (reverse xs)))) -(define-syntax quasiquote - (hygienic-macro-transformer - (lambda (template) +(experimental:define-syntax quasiquote + (experimental:er-macro-transformer + (lambda (form rename compare) (define (expand x depth) (cond ((pair? x) (cond ((free-identifier=? unquote (car x)) (if (<= depth 0) (cadr x) - (list list (list quote 'unquote) (expand (cadr x) (- depth 1))))) + (list (rename 'list) + (list (rename 'quote) 'unquote) + (expand (cadr x) (- depth 1))))) ((free-identifier=? unquote-splicing (car x)) (if (<= depth 0) - (list cons (expand (car x) depth) - (expand (cdr x) depth)) - (list list (list quote 'unquote-splicing) - (expand (cadr x) (- depth 1))))) + (list (rename 'cons) + (expand (car x) depth) + (expand (cdr x) depth)) + (list (rename 'list) + (list (rename 'quote) 'unquote-splicing) + (expand (cadr x) (- depth 1))))) ((free-identifier=? quasiquote (car x)) - (list list (list quote 'quasiquote) - (expand (cadr x) (+ depth 1)))) + (list (rename 'list) + (list (rename 'quote) 'quasiquote) + (expand (cadr x) (+ depth 1)))) ((and (<= depth 0) (pair? (car x)) (free-identifier=? unquote-splicing (caar x))) (if (null? (cdr x)) - (cadr (car x)) - (list append (cadr (car x)) (expand (cdr x) depth)))) - (else (list cons (expand (car x) depth) - (expand (cdr x) depth))))) + (cadar x) + (list (rename 'append) + (cadar x) + (expand (cdr x) depth)))) + (else (list (rename 'cons) + (expand (car x) depth) + (expand (cdr x) depth))))) ((vector? x) - (list list->vector (expand (vector->list x) depth))) + (list (rename 'list->vector) + (expand (vector->list x) depth))) ((or (identifier? x) (null? x)) - (list quote x)) + (list (rename 'quote) x)) (else x))) - (expand template 0)))) + (expand (cadr form) 0)))) (define (not x) (if x #f #t)) @@ -220,13 +232,16 @@ #f) (any-2+ f (cons x xs)))) -(define-syntax let - (hygienic-macro-transformer - (lambda (bindings . body) - (if (identifier? bindings) - `(,letrec ((,bindings (,lambda ,(map car (car body)) ,@(cdr body)))) - (,bindings ,@(map cadr (car body)))) - `((,lambda ,(map car bindings) ,@body) ,@(map cadr bindings)))))) +(experimental:define-syntax let + (experimental:er-macro-transformer + (lambda (form rename compare) + (if (identifier? (cadr form)) + `(,(rename 'letrec) ((,(cadr form) + (,(rename 'lambda) ,(map car (caddr form)) ,@(cdddr form)))) + (,(cadr form) ,@(map cadr (caddr form)))) + `((,(rename 'lambda) ,(map car (cadr form)) ,@(cddr form)) + ,@(map cadr (cadr form))))))) + (experimental:define-syntax let* (experimental:er-macro-transformer @@ -254,44 +269,49 @@ (define (memq o x) (member o x eq?)) (define (memv o x) (member o x eqv?)) -(define-syntax case - (hygienic-macro-transformer - (lambda (key . clauses) - (define (body expressions) - (cond ((null? expressions) result) - ((free-identifier=? => (car expressions)) `(,(cadr expressions) ,result)) - (else `(,begin ,@expressions)))) +(experimental:define-syntax case + (experimental:er-macro-transformer + (lambda (form rename compare) + (define (body xs) + (cond ((null? xs) result) + ((free-identifier=? => (car xs)) `(,(cadr xs) ,result)) + (else `(,(rename 'begin) ,@xs)))) (define (each-clause clauses) - (cond ((null? clauses) (unspecified)) + (cond ((null? clauses) + (unspecified)) ((free-identifier=? else (caar clauses)) (body (cdar clauses))) ((and (pair? (caar clauses)) (null? (cdr (caar clauses)))) - `(,if (,eqv? ,result (,quote ,(car (caar clauses)))) - ,(body (cdar clauses)) + `(,(rename 'if) (,(rename 'eqv?) ,result (,(rename 'quote) ,(caaar clauses))) + ,(body (cdar clauses)) ,(each-clause (cdr clauses)))) - (else `(,if (,memv ,result (,quote ,(caar clauses))) - ,(body (cdar clauses)) - ,(each-clause (cdr clauses)))))) - `(,let ((,result ,key)) ,(each-clause clauses))))) - -(define-syntax do - (hygienic-macro-transformer - (lambda (variables test . commands) - (let ((body `(,begin ,@commands - (,rec ,@(map (lambda (x) - (if (pair? (cddr x)) - (car (cddr x)) - (car x))) - variables))))) - `(,let ,rec ,(map (lambda (x) - (list (car x) - (cadr x))) - variables) - ,(if (null? (cdr test)) - `(,let ((,result ,(car test))) - (,if ,result ,result ,body)) - `(,if ,(car test) (,begin ,@(cdr test)) ,body))))))) + (else `(,(rename 'if) (,(rename 'memv) ,result (,(rename 'quote) ,(caar clauses))) + ,(body (cdar clauses)) + ,(each-clause (cdr clauses)))))) + `(,(rename 'let) ((,result ,(cadr form))) ,(each-clause (cddr form)))))) + +(experimental:define-syntax do + (experimental:er-macro-transformer + (lambda (form rename compare) + (let ((body `(,(rename 'begin) ,(cdddr form) + (,rec ,@(map (lambda (x) + (if (pair? (cddr x)) + (caddr x) + (car x))) + (cadr form)))))) + `(,(rename 'let) ,rec ,(map (lambda (x) + (list (car x) + (cadr x))) + (cadr form)) + ,(if (null? (cdaddr form)) + `(,(rename 'let) ((,result ,(caaddr form))) + (,(rename 'if) ,result + ,result + ,body)) + `(,(rename 'if) ,(caaddr form) + (,(rename 'begin) ,@(cdaddr form)) + ,body))))))) ; ---- 6.1. Equivalence predicates --------------------------------------------- diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index f2c96f375..c41ad52d2 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1931,6 +1931,34 @@ namespace meevax return make(car(xs), cadr(xs), caddr(xs)); }); + define("syntactic-closure?", [](let const& xs, auto&&...) + { + return car(xs).is(); + }); + + define("identifier=?", [](let const& xs, auto&&...) + { + let const& e1 = car(xs), + x = cadr(xs), + rx = x.is() ? x : make(e1, unit, x), + e2 = caddr(xs), + y = cadddr(xs), + ry = y.is() ? y : make(e2, unit, y); + + let const& n1 = rx.as().notate(); + PRINT(n1); + + let const& n2 = ry.as().notate(); + PRINT(n2); + + auto const result = eqv(n1, n2); + + LINE(); + PRINT(result); + + return result; + }); + define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { return make(car(xs), current_environment.fork(current_syntactic_environment)); diff --git a/test/identifier.ss b/test/identifier.ss index 72fcc2b6a..b6fbb0e9e 100644 --- a/test/identifier.ss +++ b/test/identifier.ss @@ -1,13 +1,55 @@ +(define (experimental:er-macro-transformer f) + (lambda (form use-env mac-env) + (define (rename x) + (make-syntactic-closure mac-env '() x)) + (define (compare x y) + (identifier=? use-env x use-env y)) + (f form rename compare))) + (define value 42) ; ------------------------------------------------------------------------------ -; (check (identifier? (identifier 'value)) => #t) +(experimental:define-syntax er-macro-transformer:rename + (experimental:er-macro-transformer + (lambda (form rename compare) + (rename (cadr form))))) (check (identifier? 'value) => #t) (check (identifier? 3) => #f) +(check value => 42) +(check (er-macro-transformer:rename value) => 42) + +(let ((value 3.14)) + (check value => 3.14) + (check (er-macro-transformer:rename value) => 42)) + +; ------------------------------------------------------------------------------ + +(experimental:define-syntax er-macro-transformer:compare + (experimental:er-macro-transformer + (lambda (form rename compare) + (let ((x (cadr form)) + (y (rename x))) + (check (identifier? x) => #t) + (check (identifier? y) => #t) + (check (symbol? x) => #t) + (check (syntactic-closure? y) => #t) + (compare x (rename x)) + ) + ) + ) + ) + +(check (er-macro-transformer:compare value) => #t) + +(let ((value 3.14)) + (check (er-macro-transformer:compare value) => #f)) + +(check (er-macro-transformer:compare else) => #t) + ; ------------------------------------------------------------------------------ ; (check (identifier->symbol (identifier 'value)) => value) From 8d8490fbbb86e0fe3abaecb37d91bb7ec9d2c741 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 20 Apr 2022 00:38:20 +0900 Subject: [PATCH 102/118] Remove `hygienic_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 17 ----------------- src/library/meevax.cpp | 5 ----- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 706467cf0..730e04482 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.929.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.930.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.929_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.930_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.929 +Meevax Lisp System, version 0.3.930 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index ed2dc7a03..079452d28 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.929 +0.3.930 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 6e248ac85..d56a7d63b 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -93,23 +93,6 @@ inline namespace kernel * --------------------------------------------------------------------- */ }; - struct hygienic_macro_transformer : public transformer - { - using transformer::expression; - using transformer::mac_env; - using transformer::transformer; - - auto expand(const_reference form, const_reference) -> object override - { - return mac_env.template as().apply(expression, cdr(form)); - } - - friend auto operator <<(std::ostream & os, hygienic_macro_transformer const& datum) -> std::ostream & - { - return os << magenta("#,(") << green("hygienic-macro-transformer ") << faint("#;", &datum) << magenta(")"); - } - }; - struct generic_macro_transformer : public transformer { using transformer::expression; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index c41ad52d2..7b3fd658d 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1921,11 +1921,6 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { - define("hygienic-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) - { - return make(car(xs), current_environment.fork(current_syntactic_environment)); - }); - define("make-syntactic-closure", [](let const& xs, auto&&...) { return make(car(xs), cadr(xs), caddr(xs)); From 8cb229c00f10bae021c6d24ec82d6e82a396d158 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 20 Apr 2022 02:47:40 +0900 Subject: [PATCH 103/118] Update `rename` to acts as a mathematical function Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- basis/overture.ss | 74 +++++++++++++++++++++++++++-------------------- 3 files changed, 47 insertions(+), 35 deletions(-) diff --git a/README.md b/README.md index 730e04482..28f05a071 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.930.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.931.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.930_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.931_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.930 +Meevax Lisp System, version 0.3.931 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 079452d28..5bc3cf0de 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.930 +0.3.931 diff --git a/basis/overture.ss b/basis/overture.ss index d52caedb3..e39e378ba 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -20,11 +20,21 @@ (define (experimental:er-macro-transformer f) (lambda (form use-env mac-env) + (define rename:list (list)) (define (rename x) - (make-syntactic-closure mac-env '() x)) + (letrec ((assq (lambda (x alist) + (if (null? alist) #f + (if (eq? x (caar alist)) + (car alist) + (assq x (cdr alist)))))) + (alist-cons (lambda (key x alist) + (cons (cons key x) alist)))) + (define cell (assq x rename:list)) + (if cell + (cdr cell) + (begin (set! rename:list (alist-cons x (make-syntactic-closure mac-env '() x) rename:list)) + (cdar rename:list))))) (define (compare x y) - (define (identifier=? e1 x e2 y) - (eqv? x y)) (identifier=? use-env x use-env y)) (f form rename compare))) @@ -43,18 +53,18 @@ (if (null? (cdr form)) (unspecified) ((lambda (clause) - (if (free-identifier=? else (car clause)) + (if (compare (rename 'else) (car clause)) (cons (rename 'begin) (cdr clause)) (if (if (null? (cdr clause)) #t (free-identifier=? => (cadr clause))) (list (list (rename 'lambda) - (list result) + (list (rename 'result)) (list (rename 'if) - result + (rename 'result) (if (null? (cdr clause)) - result + (rename 'result) (list (caddr clause) - result)) + (rename 'result))) (cons (rename 'cond) (cddr form)))) (car clause)) (list (rename 'if) @@ -78,15 +88,14 @@ (experimental:define-syntax or (experimental:er-macro-transformer (lambda (form rename compare) - (define RESULT (rename 'result)) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) (else (list (list (rename 'lambda) - (list RESULT) + (list (rename 'result)) (list (rename 'if) - RESULT - RESULT + (rename 'result) + (rename 'result) (cons (rename 'or) (cddr form)))) (cadr form))))))) @@ -273,8 +282,8 @@ (experimental:er-macro-transformer (lambda (form rename compare) (define (body xs) - (cond ((null? xs) result) - ((free-identifier=? => (car xs)) `(,(cadr xs) ,result)) + (cond ((null? xs) (rename 'result)) + ((free-identifier=? => (car xs)) `(,(cadr xs) ,(rename 'result))) (else `(,(rename 'begin) ,@xs)))) (define (each-clause clauses) (cond ((null? clauses) @@ -282,32 +291,35 @@ ((free-identifier=? else (caar clauses)) (body (cdar clauses))) ((and (pair? (caar clauses)) - (null? (cdr (caar clauses)))) - `(,(rename 'if) (,(rename 'eqv?) ,result (,(rename 'quote) ,(caaar clauses))) + (null? (cdaar clauses))) + `(,(rename 'if) (,(rename 'eqv?) ,(rename 'result) + (,(rename 'quote) ,(caaar clauses))) ,(body (cdar clauses)) - ,(each-clause (cdr clauses)))) - (else `(,(rename 'if) (,(rename 'memv) ,result (,(rename 'quote) ,(caar clauses))) + ,(each-clause (cdr clauses)))) + (else `(,(rename 'if) (,(rename 'memv) ,(rename 'result) + (,(rename 'quote) ,(caar clauses))) ,(body (cdar clauses)) ,(each-clause (cdr clauses)))))) - `(,(rename 'let) ((,result ,(cadr form))) ,(each-clause (cddr form)))))) + `(,(rename 'let) ((,(rename 'result) ,(cadr form))) + ,(each-clause (cddr form)))))) (experimental:define-syntax do (experimental:er-macro-transformer (lambda (form rename compare) (let ((body `(,(rename 'begin) ,(cdddr form) - (,rec ,@(map (lambda (x) - (if (pair? (cddr x)) - (caddr x) - (car x))) - (cadr form)))))) - `(,(rename 'let) ,rec ,(map (lambda (x) - (list (car x) - (cadr x))) - (cadr form)) + (,(rename 'rec) ,@(map (lambda (x) + (if (pair? (cddr x)) + (caddr x) + (car x))) + (cadr form)))))) + `(,(rename 'let) ,(rename 'rec) ,(map (lambda (x) + (list (car x) + (cadr x))) + (cadr form)) ,(if (null? (cdaddr form)) - `(,(rename 'let) ((,result ,(caaddr form))) - (,(rename 'if) ,result - ,result + `(,(rename 'let) ((,(rename 'result) ,(caaddr form))) + (,(rename 'if) ,(rename 'result) + ,(rename 'result) ,body)) `(,(rename 'if) ,(caaddr form) (,(rename 'begin) ,@(cdaddr form)) From 11144b5b3f06ca3e3924169fc297a754b0b3f346 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Wed, 20 Apr 2022 03:05:28 +0900 Subject: [PATCH 104/118] Lipsticks Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/srfi-39.ss | 10 ---------- src/library/meevax.cpp | 8 ++++---- test/chibi-basic.ss | 4 ++-- 5 files changed, 10 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 28f05a071..a7a5a967e 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.931.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.932.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.931_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.932_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.931 +Meevax Lisp System, version 0.3.932 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 5bc3cf0de..ca8fa176b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.931 +0.3.932 diff --git a/basis/srfi-39.ss b/basis/srfi-39.ss index bbf94fa7a..bad07d511 100644 --- a/basis/srfi-39.ss +++ b/basis/srfi-39.ss @@ -64,16 +64,6 @@ (define (dynamic-env-local-set! new-env) (set! dynamic-env-local new-env)) -; (define-syntax parameterize -; (er-macro-transformer -; (lambda (form rename compare) -; (let* ((bindings (cadr form)) -; (body (cddr form))) -; `(dynamic-bind -; (list ,@(map car bindings)) -; (list ,@(map cadr bindings)) -; (lambda () ,@body)))))) - (experimental:define-syntax parameterize (experimental:er-macro-transformer (lambda (form rename compare) diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 7b3fd658d..f9d0f04c0 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1941,15 +1941,15 @@ namespace meevax ry = y.is() ? y : make(e2, unit, y); let const& n1 = rx.as().notate(); - PRINT(n1); + // PRINT(n1); let const& n2 = ry.as().notate(); - PRINT(n2); + // PRINT(n2); auto const result = eqv(n1, n2); - LINE(); - PRINT(result); + // LINE(); + // PRINT(result); return result; }); diff --git a/test/chibi-basic.ss b/test/chibi-basic.ss index 7475855e7..c7536e8d4 100644 --- a/test/chibi-basic.ss +++ b/test/chibi-basic.ss @@ -201,8 +201,8 @@ (let ((tmp 5)) (myor #f tmp))) => 5) -(define-syntax myor - (er-macro-transformer +(experimental:define-syntax myor + (experimental:er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f (list (rename 'let) (list (list (rename 'tmp) (cadr expr))) From e48ed0a1869eb9f60867dae365e83735fb4bdddd Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 23 Apr 2022 16:12:49 +0900 Subject: [PATCH 105/118] Add experimental mnemonic `let_syntax_` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/instruction.hpp | 1 + src/kernel/instruction.cpp | 2 ++ 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a7a5a967e..f30e7f632 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.932.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.933.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.932_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.933_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.932 +Meevax Lisp System, version 0.3.933 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index ca8fa176b..d3be0b4d2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.932 +0.3.933 diff --git a/include/meevax/kernel/instruction.hpp b/include/meevax/kernel/instruction.hpp index 4bcf2a372..4def1587c 100644 --- a/include/meevax/kernel/instruction.hpp +++ b/include/meevax/kernel/instruction.hpp @@ -33,6 +33,7 @@ inline namespace kernel dummy, // a.k.a DUM join, // let_syntax, // + let_syntax_, // EXPERIMENTAL letrec, // a.k.a RAP letrec_syntax, // load_absolute, // a.k.a LDG diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 5799f97af..4b32712a5 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -33,6 +33,7 @@ inline namespace kernel case mnemonic::dummy: return "dummy"; case mnemonic::join: return "join"; case mnemonic::let_syntax: return "let-syntax"; + case mnemonic::let_syntax_: return "experimental:let-syntax"; case mnemonic::letrec: return "letrec"; case mnemonic::letrec_syntax: return "letrec-syntax"; case mnemonic::load_absolute: return "load-absolute"; @@ -99,6 +100,7 @@ inline namespace kernel case mnemonic::define: case mnemonic::define_syntax: case mnemonic::let_syntax: + case mnemonic::let_syntax_: case mnemonic::letrec_syntax: case mnemonic::load_absolute: case mnemonic::load_constant: From 747f8f3ebd9a76f7bfc6432097a11fd608a56d9b Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 23 Apr 2022 17:53:37 +0900 Subject: [PATCH 106/118] Add experimental syntax `experimental:let-syntax` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/machine.hpp | 49 +++++++++++++++++++++++++++++++ src/library/meevax.cpp | 1 + test/let-syntax.ss | 19 ++++++------ 5 files changed, 63 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f30e7f632..aef8ef45e 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.933.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.934.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.933_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.934_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.933 +Meevax Lisp System, version 0.3.934 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index d3be0b4d2..7f672837f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.933 +0.3.934 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index d56a7d63b..771ef841e 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -474,6 +474,35 @@ inline namespace kernel ).template as()); goto decode; + case mnemonic::let_syntax_: /* ------------------------------------------- + * + * s e (%experimental:let-syntax . c) d => s e c' d + * + * ------------------------------------------------------------------- */ + [&]() + { + let const& syntactic_environment = cadr(c).template as().syntactic_environment(); + + for (let const& keyword_ : car(syntactic_environment)) + { + let & binding = keyword_.as().strip(); + + let const& f = environment(static_cast(*this)).execute(binding); + + binding = make(f, static_cast(*this).fork(unit)); + } + }(); + + std::swap(c.as(), + body(context::none, + static_cast(*this), + cadr(c).template as().expression(), + cadr(c).template as().syntactic_environment(), + cddr(c) + ).template as()); + + goto decode; + case mnemonic::letrec_syntax: /* ----------------------------------------- * * s e (%letrec-syntax . c) d => s e c' d @@ -1116,6 +1145,26 @@ inline namespace kernel current_continuation); } + static SYNTAX(let_syntax_) + { + auto make_keyword = [&](let const& binding) + { + return make(car(binding), + compile(context::outermost, + current_environment, + cadr(binding), + current_syntactic_environment)); + }; + + auto const [bindings, body] = unpair(current_expression); + + return cons(make(mnemonic::let_syntax_), + make(body, + cons(map(make_keyword, bindings), + current_syntactic_environment)), + current_continuation); + } + static SYNTAX(letrec_syntax) /* -------------------------------------------- * * (letrec-syntax ) syntax diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index f9d0f04c0..d0a562508 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -30,6 +30,7 @@ namespace meevax define("if", if_); define("lambda", lambda); define("let-syntax", let_syntax); + define("experimental:let-syntax", let_syntax_); define("letrec", letrec); define("letrec-syntax", letrec_syntax); define("quote", quote); diff --git a/test/let-syntax.ss b/test/let-syntax.ss index ec305c7fb..9f200a2ad 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -9,13 +9,12 @@ (let ((f (lambda (a) (+ a 2)))) (set! result (cons (f 0) result)) - - (let-syntax ((f (er-macro-transformer - (lambda (form rename compare) - `(,(rename '+) ,(cadr form) 3)))) - (g (er-macro-transformer - (lambda (form rename compare) - '())))) + (experimental:let-syntax ((f (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename '+) ,(cadr form) 3)))) + (g (experimental:er-macro-transformer + (lambda (form rename compare) + '())))) (set! result (cons (f 0) result)) (let ((f (lambda (a) (+ a 4)))) @@ -29,9 +28,9 @@ (define (double-y) (let ((+y (lambda (x) (+ x y)))) - (let-syntax ((macro (er-macro-transformer - (lambda (form rename compare) - `(,(rename '+) ,(cadr form) ,(+y 0)))))) + (experimental:let-syntax ((macro (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename '+) ,(cadr form) ,(+y 0)))))) (macro y)))) (check (double-y) => 200) From 44dab03131788ef635b287ec4fbc53d9fc987b40 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 23 Apr 2022 18:17:43 +0900 Subject: [PATCH 107/118] Replace syntax `let-syntax` with experimental version Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/instruction.hpp | 1 - include/meevax/kernel/machine.hpp | 44 --------------------------- src/kernel/instruction.cpp | 2 -- src/library/meevax.cpp | 1 - test/let-syntax.ss | 18 +++++------ test/r5rs.ss | 16 +++++----- test/r7rs.ss | 22 +++++++------- 9 files changed, 32 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index aef8ef45e..2071241f9 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.934.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.935.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.934_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.935_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.934 +Meevax Lisp System, version 0.3.935 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 7f672837f..aa556d443 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.934 +0.3.935 diff --git a/include/meevax/kernel/instruction.hpp b/include/meevax/kernel/instruction.hpp index 4def1587c..4bcf2a372 100644 --- a/include/meevax/kernel/instruction.hpp +++ b/include/meevax/kernel/instruction.hpp @@ -33,7 +33,6 @@ inline namespace kernel dummy, // a.k.a DUM join, // let_syntax, // - let_syntax_, // EXPERIMENTAL letrec, // a.k.a RAP letrec_syntax, // load_absolute, // a.k.a LDG diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 771ef841e..9535a6c80 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -457,32 +457,6 @@ inline namespace kernel { let const& syntactic_environment = cadr(c).template as().syntactic_environment(); - for (let const& keyword_ : car(syntactic_environment)) - { - let & binding = keyword_.as().strip(); - - binding = environment(static_cast(*this)).execute(binding); - } - }(); - - std::swap(c.as(), - body(context::none, - static_cast(*this), - cadr(c).template as().expression(), - cadr(c).template as().syntactic_environment(), - cddr(c) - ).template as()); - goto decode; - - case mnemonic::let_syntax_: /* ------------------------------------------- - * - * s e (%experimental:let-syntax . c) d => s e c' d - * - * ------------------------------------------------------------------- */ - [&]() - { - let const& syntactic_environment = cadr(c).template as().syntactic_environment(); - for (let const& keyword_ : car(syntactic_environment)) { let & binding = keyword_.as().strip(); @@ -1141,24 +1115,6 @@ inline namespace kernel auto const [bindings, body] = unpair(current_expression); return cons(make(mnemonic::let_syntax), - make(body, cons(map(make_keyword, bindings), current_syntactic_environment)), - current_continuation); - } - - static SYNTAX(let_syntax_) - { - auto make_keyword = [&](let const& binding) - { - return make(car(binding), - compile(context::outermost, - current_environment, - cadr(binding), - current_syntactic_environment)); - }; - - auto const [bindings, body] = unpair(current_expression); - - return cons(make(mnemonic::let_syntax_), make(body, cons(map(make_keyword, bindings), current_syntactic_environment)), diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 4b32712a5..5799f97af 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -33,7 +33,6 @@ inline namespace kernel case mnemonic::dummy: return "dummy"; case mnemonic::join: return "join"; case mnemonic::let_syntax: return "let-syntax"; - case mnemonic::let_syntax_: return "experimental:let-syntax"; case mnemonic::letrec: return "letrec"; case mnemonic::letrec_syntax: return "letrec-syntax"; case mnemonic::load_absolute: return "load-absolute"; @@ -100,7 +99,6 @@ inline namespace kernel case mnemonic::define: case mnemonic::define_syntax: case mnemonic::let_syntax: - case mnemonic::let_syntax_: case mnemonic::letrec_syntax: case mnemonic::load_absolute: case mnemonic::load_constant: diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index d0a562508..f9d0f04c0 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -30,7 +30,6 @@ namespace meevax define("if", if_); define("lambda", lambda); define("let-syntax", let_syntax); - define("experimental:let-syntax", let_syntax_); define("letrec", letrec); define("letrec-syntax", letrec_syntax); define("quote", quote); diff --git a/test/let-syntax.ss b/test/let-syntax.ss index 9f200a2ad..1a562290a 100644 --- a/test/let-syntax.ss +++ b/test/let-syntax.ss @@ -9,12 +9,12 @@ (let ((f (lambda (a) (+ a 2)))) (set! result (cons (f 0) result)) - (experimental:let-syntax ((f (experimental:er-macro-transformer - (lambda (form rename compare) - `(,(rename '+) ,(cadr form) 3)))) - (g (experimental:er-macro-transformer - (lambda (form rename compare) - '())))) + (let-syntax ((f (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename '+) ,(cadr form) 3)))) + (g (experimental:er-macro-transformer + (lambda (form rename compare) + '())))) (set! result (cons (f 0) result)) (let ((f (lambda (a) (+ a 4)))) @@ -28,9 +28,9 @@ (define (double-y) (let ((+y (lambda (x) (+ x y)))) - (experimental:let-syntax ((macro (experimental:er-macro-transformer - (lambda (form rename compare) - `(,(rename '+) ,(cadr form) ,(+y 0)))))) + (let-syntax ((macro (experimental:er-macro-transformer + (lambda (form rename compare) + `(,(rename '+) ,(cadr form) ,(+y 0)))))) (macro y)))) (check (double-y) => 200) diff --git a/test/r5rs.ss b/test/r5rs.ss index af0de0db5..6faec78be 100644 --- a/test/r5rs.ss +++ b/test/r5rs.ss @@ -210,14 +210,14 @@ ; ---- 4.3.1 ------------------------------------------------------------------- -(check (let-syntax ((when (syntax-rules () - ((when test stmt1 stmt2 ...) - (if test - (begin stmt1 - stmt2 ...)))))) - (let ((if #t)) - (when if (set! if 'now)) - if)) => now) +; (check (let-syntax ((when (syntax-rules () +; ((when test stmt1 stmt2 ...) +; (if test +; (begin stmt1 +; stmt2 ...)))))) +; (let ((if #t)) +; (when if (set! if 'now)) +; if)) => now) ; (check (let ((x 'outer)) ; (let-syntax ((m (syntax-rules () ((m) x)))) diff --git a/test/r7rs.ss b/test/r7rs.ss index d50457763..c4695b43b 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -345,20 +345,20 @@ ; ---- 4.3.1. Binding constructs for syntactic keywords ------------------------ -(check (let-syntax ((given-that (syntax-rules () - ((given-that test stmt1 stmt2 ...) - (if test - (begin stmt1 - stmt2 ...)))))) - (let ((if #t)) - (given-that if (set! if 'now)) - if)) => now) +; (check (let-syntax ((given-that (syntax-rules () +; ((given-that test stmt1 stmt2 ...) +; (if test +; (begin stmt1 +; stmt2 ...)))))) +; (let ((if #t)) +; (given-that if (set! if 'now)) +; if)) => now) (check (let ((x 'outer)) (let-syntax ((m ; (syntax-rules () ((m) x)) ; BUG - (er-macro-transformer - (lambda (form rename compare) - (list (rename 'quote) x))))) + (experimental:er-macro-transformer + (lambda (form rename compare) + (list (rename 'quote) x))))) (let ((x 'inner)) (m)))) => outer) From c1902e11311686158967409dbebfe0d8fe28bd04 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sat, 23 Apr 2022 18:52:35 +0900 Subject: [PATCH 108/118] Update syntax `letrec-syntax` to receive closure as transformer spec Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 4 ++-- test/chibi-basic.ss | 4 ++-- test/letrec-syntax.ss | 4 ++-- test/r5rs.ss | 34 +++++++++++++++---------------- test/r7rs.ss | 2 +- 7 files changed, 28 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 2071241f9..30caad93b 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.935.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.936.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.935_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.936_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.935 +Meevax Lisp System, version 0.3.936 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index aa556d443..1f34f8176 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.935 +0.3.936 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 9535a6c80..3d7774ee8 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -450,7 +450,7 @@ inline namespace kernel case mnemonic::let_syntax: /* -------------------------------------------- * - * s e (%let_syntax . c) d => s e c' d + * s e (%let-syntax . c) d => s e c' d * * ------------------------------------------------------------------- */ [&]() @@ -492,7 +492,7 @@ inline namespace kernel { env.execute(compile(context::outermost, env, - cons(make("define-syntax", define), transformer_spec), + cons(make("define-syntax", define_syntax), transformer_spec), cadr(c).template as().syntactic_environment())); } diff --git a/test/chibi-basic.ss b/test/chibi-basic.ss index c7536e8d4..3e142d59d 100644 --- a/test/chibi-basic.ss +++ b/test/chibi-basic.ss @@ -190,7 +190,7 @@ (check (letrec-syntax ((myor - (er-macro-transformer + (experimental:er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f @@ -263,7 +263,7 @@ (check (letrec-syntax ((myor - (er-macro-transformer + (experimental:er-macro-transformer (lambda (expr rename compare) (if (null? (cdr expr)) #f diff --git a/test/letrec-syntax.ss b/test/letrec-syntax.ss index 1bc86ebdc..d7fbc70a1 100644 --- a/test/letrec-syntax.ss +++ b/test/letrec-syntax.ss @@ -2,7 +2,7 @@ (scheme base) (srfi 78)) -(letrec-syntax ((my-and (er-macro-transformer +(letrec-syntax ((my-and (experimental:er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #t) ((null? (cddr form)) (cadr form)) @@ -12,7 +12,7 @@ #f))))))) (check (my-and #t #t #f #t) => #f)) -(letrec-syntax ((my-or (er-macro-transformer +(letrec-syntax ((my-or (experimental:er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) diff --git a/test/r5rs.ss b/test/r5rs.ss index 6faec78be..e9dc306d6 100644 --- a/test/r5rs.ss +++ b/test/r5rs.ss @@ -224,23 +224,23 @@ ; (let ((x 'inner)) ; (m)))) => outer) ; ERROR -(check (letrec-syntax ((my-or (syntax-rules () - ((my-or) #f) - ((my-or e) e) - ((my-or e1 e2 ...) - (let ((temp e1)) - (if temp - temp - (my-or e2 ...))))))) - (let ((x #f) - (y 7) - (temp 8) - (let odd?) - (if even?)) - (my-or x - (let temp) - (if y) - y))) => 7) +; (check (letrec-syntax ((my-or (syntax-rules () +; ((my-or) #f) +; ((my-or e) e) +; ((my-or e1 e2 ...) +; (let ((temp e1)) +; (if temp +; temp +; (my-or e2 ...))))))) +; (let ((x #f) +; (y 7) +; (temp 8) +; (let odd?) +; (if even?)) +; (my-or x +; (let temp) +; (if y) +; y))) => 7) ; ---- 4.3.2 ------------------------------------------------------------------- diff --git a/test/r7rs.ss b/test/r7rs.ss index c4695b43b..9a2a01b45 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -368,7 +368,7 @@ ; ((my-or e1 e2 ...) ; (let ((temp e1)) ; (if temp temp (my-or e2 ...))))) - (er-macro-transformer + (experimental:er-macro-transformer (lambda (form rename compare) (cond ((null? (cdr form)) #f) ((null? (cddr form)) (cadr form)) From ed42693e2aafc0ee2ff60d256f111999ded133ff Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Sun, 24 Apr 2022 02:45:06 +0900 Subject: [PATCH 109/118] Fix some syntax definitions Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/overture.ss | 11 ++++++----- test/er-macro-transformer.ss | 6 +++--- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 30caad93b..b268f1611 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.936.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.938.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.936_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.938_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.936 +Meevax Lisp System, version 0.3.938 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 1f34f8176..072000479 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.936 +0.3.938 diff --git a/basis/overture.ss b/basis/overture.ss index e39e378ba..1d264d449 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -264,7 +264,8 @@ (experimental:define-syntax letrec* (experimental:er-macro-transformer (lambda (form rename compare) - `(,(rename 'let) ,@(map (lambda (x) (cons (rename 'define) x)) + `(,(rename 'let) () + ,@(map (lambda (x) (cons (rename 'define) x)) (cadr form)) ,@(cddr form))))) @@ -306,7 +307,7 @@ (experimental:define-syntax do (experimental:er-macro-transformer (lambda (form rename compare) - (let ((body `(,(rename 'begin) ,(cdddr form) + (let ((body `(,(rename 'begin) ,@(cdddr form) (,(rename 'rec) ,@(map (lambda (x) (if (pair? (cddr x)) (caddr x) @@ -317,9 +318,9 @@ (cadr x))) (cadr form)) ,(if (null? (cdaddr form)) - `(,(rename 'let) ((,(rename 'result) ,(caaddr form))) - (,(rename 'if) ,(rename 'result) - ,(rename 'result) + `(,(rename 'let) ((,(rename 'it) ,(caaddr form))) + (,(rename 'if) ,(rename 'it) + ,(rename 'it) ,body)) `(,(rename 'if) ,(caaddr form) (,(rename 'begin) ,@(cdaddr form)) diff --git a/test/er-macro-transformer.ss b/test/er-macro-transformer.ss index c5f5a82f7..b70678e1c 100644 --- a/test/er-macro-transformer.ss +++ b/test/er-macro-transformer.ss @@ -17,8 +17,8 @@ ; ------------------------------------------------------------------------------ -(define-syntax swap! - (er-macro-transformer +(experimental:define-syntax swap! + (experimental:er-macro-transformer (lambda (form rename compare) (let ((a (cadr form)) (b (caddr form))) @@ -26,7 +26,7 @@ (,(rename 'set!) ,a ,b) (,(rename 'set!) ,b ,(rename 'x))))))) -(check (er-macro-transformer? swap!) => #t) +(check (transformer? swap!) => #t) (define x 1) From 6cc215a646bf2d33f56e7d89e25fdb27afa2d160 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 25 Apr 2022 01:54:15 +0900 Subject: [PATCH 110/118] =?UTF-8?q?Fix=20procedure=20`identifier=3D=3F`=20?= =?UTF-8?q?to=20work=20correctly?= Signed-off-by: yamacir-kit --- README.md | 6 ++--- VERSION | 2 +- basis/srfi-149.ss | 4 +-- include/meevax/kernel/machine.hpp | 16 ++++++------ src/library/meevax.cpp | 42 ++++++++++++++++++++++++++++++- 5 files changed, 55 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b268f1611..e8ec42c80 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.938.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.939.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.938_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.939_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.938 +Meevax Lisp System, version 0.3.939 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 072000479..903a89cb9 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.938 +0.3.939 diff --git a/basis/srfi-149.ss b/basis/srfi-149.ss index c8f0b3c16..d1e07a0a1 100644 --- a/basis/srfi-149.ss +++ b/basis/srfi-149.ss @@ -267,7 +267,7 @@ (list (rename 'strip-syntactic-closures) _expr)) #f))))))))) -(define-syntax syntax-rules - (er-macro-transformer +(experimental:define-syntax syntax-rules + (experimental:er-macro-transformer (lambda (form rename compare) (syntax-rules-transformer form rename compare)))) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 3d7774ee8..13ca93a6a 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -1220,16 +1220,16 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - // if (car(current_expression).is_also()) - // { - // return cons(car(current_expression).as().make_load_instruction(), car(current_expression), - // current_continuation); - // } - // else - // { + if (car(current_expression).is()) + { + return cons(make(mnemonic::load_constant), car(current_expression).as().expression, + current_continuation); + } + else + { return cons(make(mnemonic::load_constant), car(current_expression), current_continuation); - // } + } } static SYNTAX(quote_syntax) diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index f9d0f04c0..0e7a2a188 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1940,13 +1940,53 @@ namespace meevax y = cadddr(xs), ry = y.is() ? y : make(e2, unit, y); + auto is_same_free_identifier = [](let const& x, let const& y) + { + std::cout << "; ---- free-identifier=? -------------------------------------------------------" << std::endl; + std::cout << "; x = " << x << std::endl; + std::cout << "; y = " << y << std::endl; + + let const& x_notation = x.as().notate(); + std::cout << "; x notation is " << x_notation << std::endl; + std::cout << "; is absolute? " << std::boolalpha << x_notation.is() << std::endl; + std::cout << "; is relative? " << std::boolalpha << x_notation.is() << std::endl; + std::cout << "; is variadic? " << std::boolalpha << x_notation.is() << std::endl; + + auto x_is_free = x_notation.is() and + x_notation.as().is_free(); + std::cout << "; is free? " << std::boolalpha << x_is_free << std::endl; + + let const& y_notation = y.as().notate(); + std::cout << "; y notation is " << y_notation << std::endl; + std::cout << "; is absolute? " << std::boolalpha << y_notation.is() << std::endl; + std::cout << "; is relative? " << std::boolalpha << y_notation.is() << std::endl; + std::cout << "; is variadic? " << std::boolalpha << y_notation.is() << std::endl; + + auto y_is_free = y_notation.is() and + y_notation.as().is_free(); + std::cout << "; is free? " << std::boolalpha << y_is_free << std::endl; + + auto is_same_notation = eq(x_notation, y_notation); + std::cout << "; is same notation? = " << std::boolalpha << is_same_notation << std::endl; + + auto both_free = x_is_free and y_is_free; + std::cout << "; both free? = " << std::boolalpha << both_free << std::endl; + + auto both_same_unbound = both_free and + eqv(x.as().expression, + y.as().expression); + std::cout << "; both same unbound? = " << std::boolalpha << both_same_unbound << std::endl; + + return is_same_notation or both_same_unbound; + }; + let const& n1 = rx.as().notate(); // PRINT(n1); let const& n2 = ry.as().notate(); // PRINT(n2); - auto const result = eqv(n1, n2); + auto const result = is_same_free_identifier(rx, ry); // LINE(); // PRINT(result); From 541a07fc8461ef34285501fc1d052a5edc12d040 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 25 Apr 2022 02:22:14 +0900 Subject: [PATCH 111/118] Deprecate member function `environment::is_same_(free|bound)_identifier` Signed-off-by: yamacir-kit --- README.md | 6 +-- VERSION | 2 +- basis/overture.ss | 14 +++--- basis/srfi-78.ss | 6 +-- include/meevax/kernel/environment.hpp | 2 + src/library/meevax.cpp | 61 +++++++++++---------------- 6 files changed, 41 insertions(+), 50 deletions(-) diff --git a/README.md b/README.md index e8ec42c80..a2ebd7974 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.939.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.940.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.939_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.940_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.939 +Meevax Lisp System, version 0.3.940 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 903a89cb9..860507bf4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.939 +0.3.940 diff --git a/basis/overture.ss b/basis/overture.ss index 1d264d449..d329730f0 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -56,7 +56,7 @@ (if (compare (rename 'else) (car clause)) (cons (rename 'begin) (cdr clause)) (if (if (null? (cdr clause)) #t - (free-identifier=? => (cadr clause))) + (compare (rename '=>) (cadr clause))) (list (list (rename 'lambda) (list (rename 'result)) (list (rename 'if) @@ -127,13 +127,13 @@ (lambda (form rename compare) (define (expand x depth) (cond ((pair? x) - (cond ((free-identifier=? unquote (car x)) + (cond ((compare (rename 'unquote) (car x)) (if (<= depth 0) (cadr x) (list (rename 'list) (list (rename 'quote) 'unquote) (expand (cadr x) (- depth 1))))) - ((free-identifier=? unquote-splicing (car x)) + ((compare (rename 'unquote-splicing) (car x)) (if (<= depth 0) (list (rename 'cons) (expand (car x) depth) @@ -141,13 +141,13 @@ (list (rename 'list) (list (rename 'quote) 'unquote-splicing) (expand (cadr x) (- depth 1))))) - ((free-identifier=? quasiquote (car x)) + ((compare (rename 'quasiquote) (car x)) (list (rename 'list) (list (rename 'quote) 'quasiquote) (expand (cadr x) (+ depth 1)))) ((and (<= depth 0) (pair? (car x)) - (free-identifier=? unquote-splicing (caar x))) + (compare (rename 'unquote-splicing) (caar x))) (if (null? (cdr x)) (cadar x) (list (rename 'append) @@ -284,12 +284,12 @@ (lambda (form rename compare) (define (body xs) (cond ((null? xs) (rename 'result)) - ((free-identifier=? => (car xs)) `(,(cadr xs) ,(rename 'result))) + ((compare (rename '=>) (car xs)) `(,(cadr xs) ,(rename 'result))) (else `(,(rename 'begin) ,@xs)))) (define (each-clause clauses) (cond ((null? clauses) (unspecified)) - ((free-identifier=? else (caar clauses)) + ((compare (rename 'else) (caar clauses)) (body (cdar clauses))) ((and (pair? (caar clauses)) (null? (cdaar clauses))) diff --git a/basis/srfi-78.ss b/basis/srfi-78.ss index b6448939d..d2a2e3f8e 100644 --- a/basis/srfi-78.ss +++ b/basis/srfi-78.ss @@ -180,9 +180,9 @@ (experimental:define-syntax check (experimental:er-macro-transformer (lambda (form rename compare) - (cond ((free-identifier=? => (caddr form)) - `(,(rename 'check) ,(cadr form) (,=> ,(rename 'equal?)) ,(cadddr form))) - ((free-identifier=? => (caaddr form)) + (cond ((compare (rename '=>) (caddr form)) + `(,(rename 'check) ,(cadr form) (,(rename '=>) ,(rename 'equal?)) ,(cadddr form))) + ((compare (rename '=>) (caaddr form)) (if (<= 1 check:mode) `(,(rename 'check:proc) ',(cadr form) (,(rename 'lambda) () ,(cadr form)) diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index da3b777fc..370881295 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -86,6 +86,7 @@ inline namespace kernel return copy; } + [[deprecated]] auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool { let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; @@ -95,6 +96,7 @@ inline namespace kernel renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); }; + [[deprecated]] auto is_same_free_identifier(const_reference x, const_reference y) -> bool { let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 0e7a2a188..c3bfd4a21 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1942,56 +1942,45 @@ namespace meevax auto is_same_free_identifier = [](let const& x, let const& y) { - std::cout << "; ---- free-identifier=? -------------------------------------------------------" << std::endl; - std::cout << "; x = " << x << std::endl; - std::cout << "; y = " << y << std::endl; + // std::cout << "; ---- free-identifier=? -------------------------------------------------------" << std::endl; + // std::cout << "; x = " << x << std::endl; + // std::cout << "; y = " << y << std::endl; let const& x_notation = x.as().notate(); - std::cout << "; x notation is " << x_notation << std::endl; - std::cout << "; is absolute? " << std::boolalpha << x_notation.is() << std::endl; - std::cout << "; is relative? " << std::boolalpha << x_notation.is() << std::endl; - std::cout << "; is variadic? " << std::boolalpha << x_notation.is() << std::endl; + // std::cout << "; x notation is " << x_notation << std::endl; + // std::cout << "; is absolute? " << std::boolalpha << x_notation.is() << std::endl; + // std::cout << "; is relative? " << std::boolalpha << x_notation.is() << std::endl; + // std::cout << "; is variadic? " << std::boolalpha << x_notation.is() << std::endl; auto x_is_free = x_notation.is() and x_notation.as().is_free(); - std::cout << "; is free? " << std::boolalpha << x_is_free << std::endl; + // std::cout << "; is free? " << std::boolalpha << x_is_free << std::endl; let const& y_notation = y.as().notate(); - std::cout << "; y notation is " << y_notation << std::endl; - std::cout << "; is absolute? " << std::boolalpha << y_notation.is() << std::endl; - std::cout << "; is relative? " << std::boolalpha << y_notation.is() << std::endl; - std::cout << "; is variadic? " << std::boolalpha << y_notation.is() << std::endl; + // std::cout << "; y notation is " << y_notation << std::endl; + // std::cout << "; is absolute? " << std::boolalpha << y_notation.is() << std::endl; + // std::cout << "; is relative? " << std::boolalpha << y_notation.is() << std::endl; + // std::cout << "; is variadic? " << std::boolalpha << y_notation.is() << std::endl; auto y_is_free = y_notation.is() and y_notation.as().is_free(); - std::cout << "; is free? " << std::boolalpha << y_is_free << std::endl; + // std::cout << "; is free? " << std::boolalpha << y_is_free << std::endl; auto is_same_notation = eq(x_notation, y_notation); - std::cout << "; is same notation? = " << std::boolalpha << is_same_notation << std::endl; + // std::cout << "; is same notation? = " << std::boolalpha << is_same_notation << std::endl; auto both_free = x_is_free and y_is_free; - std::cout << "; both free? = " << std::boolalpha << both_free << std::endl; + // std::cout << "; both free? = " << std::boolalpha << both_free << std::endl; auto both_same_unbound = both_free and eqv(x.as().expression, y.as().expression); - std::cout << "; both same unbound? = " << std::boolalpha << both_same_unbound << std::endl; + // std::cout << "; both same unbound? = " << std::boolalpha << both_same_unbound << std::endl; return is_same_notation or both_same_unbound; }; - let const& n1 = rx.as().notate(); - // PRINT(n1); - - let const& n2 = ry.as().notate(); - // PRINT(n2); - - auto const result = is_same_free_identifier(rx, ry); - - // LINE(); - // PRINT(result); - - return result; + return is_same_free_identifier(rx, ry); }); define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) @@ -2058,10 +2047,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) - { - return current_environment.is_same_free_identifier(car(xs), cadr(xs)); - }); + // define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) + // { + // return current_environment.is_same_free_identifier(car(xs), cadr(xs)); + // }); /* ------------------------------------------------------------------------- * @@ -2078,10 +2067,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) - { - return current_environment.is_same_bound_identifier(car(xs), cadr(xs)); - }); + // define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) + // { + // return current_environment.is_same_bound_identifier(car(xs), cadr(xs)); + // }); /* ------------------------------------------------------------------------- * From e33aa93bcb7735383c6978a2ecd4e0b3a3f2230c Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 25 Apr 2022 02:53:16 +0900 Subject: [PATCH 112/118] =?UTF-8?q?Remove=20procedure=20`identifier=3D=3F`?= Signed-off-by: yamacir-kit --- README.md | 6 +-- VERSION | 2 +- basis/overture.ss | 5 ++- src/library/meevax.cpp | 100 ++++++++++++++++++----------------------- test/identifier.ss | 8 ---- 5 files changed, 52 insertions(+), 69 deletions(-) diff --git a/README.md b/README.md index a2ebd7974..5a09447a5 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.940.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.941.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.940_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.941_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.940 +Meevax Lisp System, version 0.3.941 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 860507bf4..f10099fde 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.940 +0.3.941 diff --git a/basis/overture.ss b/basis/overture.ss index d329730f0..7b4e61a29 100644 --- a/basis/overture.ss +++ b/basis/overture.ss @@ -35,7 +35,10 @@ (begin (set! rename:list (alist-cons x (make-syntactic-closure mac-env '() x) rename:list)) (cdar rename:list))))) (define (compare x y) - (identifier=? use-env x use-env y)) + (free-identifier=? (if (syntactic-closure? x) x + (make-syntactic-closure use-env '() x)) + (if (syntactic-closure? y) y + (make-syntactic-closure use-env '() y)))) (f form rename compare))) (define define-syntax define) diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index c3bfd4a21..92684a7f0 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1931,58 +1931,6 @@ namespace meevax return car(xs).is(); }); - define("identifier=?", [](let const& xs, auto&&...) - { - let const& e1 = car(xs), - x = cadr(xs), - rx = x.is() ? x : make(e1, unit, x), - e2 = caddr(xs), - y = cadddr(xs), - ry = y.is() ? y : make(e2, unit, y); - - auto is_same_free_identifier = [](let const& x, let const& y) - { - // std::cout << "; ---- free-identifier=? -------------------------------------------------------" << std::endl; - // std::cout << "; x = " << x << std::endl; - // std::cout << "; y = " << y << std::endl; - - let const& x_notation = x.as().notate(); - // std::cout << "; x notation is " << x_notation << std::endl; - // std::cout << "; is absolute? " << std::boolalpha << x_notation.is() << std::endl; - // std::cout << "; is relative? " << std::boolalpha << x_notation.is() << std::endl; - // std::cout << "; is variadic? " << std::boolalpha << x_notation.is() << std::endl; - - auto x_is_free = x_notation.is() and - x_notation.as().is_free(); - // std::cout << "; is free? " << std::boolalpha << x_is_free << std::endl; - - let const& y_notation = y.as().notate(); - // std::cout << "; y notation is " << y_notation << std::endl; - // std::cout << "; is absolute? " << std::boolalpha << y_notation.is() << std::endl; - // std::cout << "; is relative? " << std::boolalpha << y_notation.is() << std::endl; - // std::cout << "; is variadic? " << std::boolalpha << y_notation.is() << std::endl; - - auto y_is_free = y_notation.is() and - y_notation.as().is_free(); - // std::cout << "; is free? " << std::boolalpha << y_is_free << std::endl; - - auto is_same_notation = eq(x_notation, y_notation); - // std::cout << "; is same notation? = " << std::boolalpha << is_same_notation << std::endl; - - auto both_free = x_is_free and y_is_free; - // std::cout << "; both free? = " << std::boolalpha << both_free << std::endl; - - auto both_same_unbound = both_free and - eqv(x.as().expression, - y.as().expression); - // std::cout << "; both same unbound? = " << std::boolalpha << both_same_unbound << std::endl; - - return is_same_notation or both_same_unbound; - }; - - return is_same_free_identifier(rx, ry); - }); - define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) { return make(car(xs), current_environment.fork(current_syntactic_environment)); @@ -2047,10 +1995,50 @@ namespace meevax * * ---------------------------------------------------------------------- */ - // define("free-identifier=?", [](let const& xs, let const&, auto && current_environment) - // { - // return current_environment.is_same_free_identifier(car(xs), cadr(xs)); - // }); + define("free-identifier=?", [](let const& xs, auto&&...) + { + auto is_same_free_identifier = [](let const& x, let const& y) + { + // std::cout << "; ---- free-identifier=? -------------------------------------------------------" << std::endl; + // std::cout << "; x = " << x << std::endl; + // std::cout << "; y = " << y << std::endl; + + let const& x_notation = x.as().notate(); + // std::cout << "; x notation is " << x_notation << std::endl; + // std::cout << "; is absolute? " << std::boolalpha << x_notation.is() << std::endl; + // std::cout << "; is relative? " << std::boolalpha << x_notation.is() << std::endl; + // std::cout << "; is variadic? " << std::boolalpha << x_notation.is() << std::endl; + + auto x_is_free = x_notation.is() and + x_notation.as().is_free(); + // std::cout << "; is free? " << std::boolalpha << x_is_free << std::endl; + + let const& y_notation = y.as().notate(); + // std::cout << "; y notation is " << y_notation << std::endl; + // std::cout << "; is absolute? " << std::boolalpha << y_notation.is() << std::endl; + // std::cout << "; is relative? " << std::boolalpha << y_notation.is() << std::endl; + // std::cout << "; is variadic? " << std::boolalpha << y_notation.is() << std::endl; + + auto y_is_free = y_notation.is() and + y_notation.as().is_free(); + // std::cout << "; is free? " << std::boolalpha << y_is_free << std::endl; + + auto is_same_notation = eq(x_notation, y_notation); + // std::cout << "; is same notation? = " << std::boolalpha << is_same_notation << std::endl; + + auto both_free = x_is_free and y_is_free; + // std::cout << "; both free? = " << std::boolalpha << both_free << std::endl; + + auto both_same_unbound = both_free and + eqv(x.as().expression, + y.as().expression); + // std::cout << "; both same unbound? = " << std::boolalpha << both_same_unbound << std::endl; + + return is_same_notation or both_same_unbound; + }; + + return is_same_free_identifier(car(xs), cadr(xs)); + }); /* ------------------------------------------------------------------------- * diff --git a/test/identifier.ss b/test/identifier.ss index b6fbb0e9e..fc74b608d 100644 --- a/test/identifier.ss +++ b/test/identifier.ss @@ -1,11 +1,3 @@ -(define (experimental:er-macro-transformer f) - (lambda (form use-env mac-env) - (define (rename x) - (make-syntactic-closure mac-env '() x)) - (define (compare x y) - (identifier=? use-env x use-env y)) - (f form rename compare))) - (define value 42) ; ------------------------------------------------------------------------------ From 57c71fdde3ee02a272efa70e1d85414e561b7b53 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Mon, 25 Apr 2022 18:59:00 +0900 Subject: [PATCH 113/118] Remove struct `er_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- basis/r7rs.ss | 24 ++++++++++++------------ basis/srfi-149.ss | 2 +- include/meevax/kernel/machine.hpp | 28 ---------------------------- src/library/meevax.cpp | 10 ---------- test/r7rs.ss | 8 ++++---- 7 files changed, 21 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index 5a09447a5..01ed187f6 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.941.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.943.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.941_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.943_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.941 +Meevax Lisp System, version 0.3.943 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f10099fde..f6e7aef49 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.941 +0.3.943 diff --git a/basis/r7rs.ss b/basis/r7rs.ss index 8cb6d0aca..567f5b399 100644 --- a/basis/r7rs.ss +++ b/basis/r7rs.ss @@ -1,6 +1,6 @@ ; ---- 4.2.1. Conditionals ----------------------------------------------------- -(define-syntax cond +(experimental:define-syntax cond (syntax-rules (else =>) ((cond (else result1 result2 ...)) (begin result1 result2 ...)) @@ -26,7 +26,7 @@ (begin result1 result2 ...) (cond clause1 clause2 ...))))) -(define-syntax case ; errata version +(experimental:define-syntax case ; errata version (syntax-rules (else =>) ((case (key ...) clauses ...) @@ -59,14 +59,14 @@ (begin result1 result2 ...) (case key clause clauses ...))))) -(define-syntax and +(experimental:define-syntax and (syntax-rules () ((and) #t) ((and test) test) ((and test1 test2 ...) (if test1 (and test2 ...) #f)))) -(define-syntax or +(experimental:define-syntax or (syntax-rules () ((or) #f) ((or test) test) @@ -74,13 +74,13 @@ (let ((x test1)) (if x x (or test2 ...)))))) -(define-syntax when +(experimental:define-syntax when (syntax-rules () ((when test result1 result2 ...) (if test (begin result1 result2 ...))))) -(define-syntax unless +(experimental:define-syntax unless (syntax-rules () ((unless test result1 result2 ...) (if (not test) @@ -88,14 +88,14 @@ ; ---- 4.2.2. Binding constructs ----------------------------------------------- -(define-syntax let +(experimental:define-syntax let (syntax-rules () ((let ((name val) ...) body1 body2 ...) ((lambda (name ...) body1 body2 ...) val ...)) ((let tag ((name val) ...) body1 body2 ...) ((letrec ((tag (lambda (name ...) body1 body2 ...))) tag) val ...)))) -(define-syntax let* +(experimental:define-syntax let* (syntax-rules () ((let* () body1 body2 ...) (let () body1 body2 ...)) @@ -103,7 +103,7 @@ (let ((name1 val1)) (let* ((name2 val2) ...) body1 body2 ...))))) -(define-syntax letrec* +(experimental:define-syntax letrec* (syntax-rules () ((letrec* ((var1 init1) ...) body1 body2 ...) (let ((var1 ) ...) @@ -175,7 +175,7 @@ ; ---- 4.2.4. Iteration -------------------------------------------------------- -(define-syntax do +(experimental:define-syntax do (syntax-rules () ((do ((var init step ...) ...) (test expr ...) @@ -218,7 +218,7 @@ parameterize ; is defined in srfi-39.ss ; ---- 4.2.7. Exception handling ----------------------------------------------- -(define-syntax guard +(experimental:define-syntax guard (syntax-rules () ((guard (var clause ...) e1 e2 ...) ((call/cc @@ -243,7 +243,7 @@ parameterize ; is defined in srfi-39.ss (lambda () (apply values args))))))))))))) -(define-syntax guard-aux +(experimental:define-syntax guard-aux (syntax-rules (else =>) ((guard-aux reraise (else result1 result2 ...)) (begin result1 result2 ...)) diff --git a/basis/srfi-149.ss b/basis/srfi-149.ss index d1e07a0a1..a97ce9a80 100644 --- a/basis/srfi-149.ss +++ b/basis/srfi-149.ss @@ -43,7 +43,7 @@ (define (syntax-rules-transformer expr rename compare) (let ((ellipsis-specified? (identifier? (cadr expr))) (count 0) - (_er-macro-transformer (rename 'er-macro-transformer)) + (_er-macro-transformer (rename 'experimental:er-macro-transformer)) (_lambda (rename 'lambda)) (_let (rename 'let)) (_begin (rename 'begin)) (_if (rename 'if)) (_and (rename 'and)) (_or (rename 'or)) diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 13ca93a6a..764edb7fb 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -129,34 +129,6 @@ inline namespace kernel } }; - struct er_macro_transformer : public transformer - { - using transformer::expression; - using transformer::mac_env; - using transformer::transformer; - - auto expand(const_reference form, const_reference) -> object override - { - auto rename = make("rename", [](let const& xs, auto&&, auto&& expander) - { - // return expander.rename(car(xs), expander.syntactic_environment()); - return expander.evaluate(car(xs)); - }); - - auto compare = make("compare", [](let const& xs, let const&, environment & expander) - { - return expander.is_same_free_identifier(car(xs), cadr(xs)); - }); - - return mac_env.template as().apply(expression, list(form, rename, compare)); - } - - friend auto operator <<(std::ostream & os, er_macro_transformer const& datum) -> std::ostream & - { - return os << magenta("#,(") << green("er-macro-transformer ") << faint("#;", &datum) << magenta(")"); - } - }; - public: /* ---- R7RS 4. Expressions ------------------------------------------------ * diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 92684a7f0..659c78245 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -1931,16 +1931,6 @@ namespace meevax return car(xs).is(); }); - define("er-macro-transformer", [](let const& xs, auto&& current_syntactic_environment, auto&& current_environment) - { - return make(car(xs), current_environment.fork(current_syntactic_environment)); - }); - - define("er-macro-transformer?", [](let const& xs, auto&&...) - { - return car(xs).is(); - }); - /* ------------------------------------------------------------------------- * * (identifier? syntax-object) procedure diff --git a/test/r7rs.ss b/test/r7rs.ss index 9a2a01b45..1a7f8356b 100644 --- a/test/r7rs.ss +++ b/test/r7rs.ss @@ -387,10 +387,10 @@ ; ---- 4.3.2. Pattern language ------------------------------------------------- -(define-syntax be-like-begin +(experimental:define-syntax be-like-begin (syntax-rules () ((be-like-begin name) - (define-syntax name + (experimental:define-syntax name (syntax-rules () ((name expr (... ...)) (begin expr (... ...)))))))) @@ -399,8 +399,8 @@ (check (sequence 1 2 3 4) => 4) -; (check (let ((=> #f)) -; (cond (#t => 'ok))) => ok) +(check (let ((=> #f)) + (cond (#t => 'ok))) => ok) ; (define-syntax simple-let ; (syntax-rules () From 18257a5eac427df5e252bdc675abc4143cf97f4f Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 26 Apr 2022 00:46:21 +0900 Subject: [PATCH 114/118] Remove deprecated member function `is_same_(free|bound)_identifier` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/environment.hpp | 20 -------------------- src/library/meevax.cpp | 2 +- 4 files changed, 5 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 01ed187f6..137eb3037 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.943.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.944.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.943_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.944_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.943 +Meevax Lisp System, version 0.3.944 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f6e7aef49..f2ba09434 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.943 +0.3.944 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 370881295..091f39adc 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -86,26 +86,6 @@ inline namespace kernel return copy; } - [[deprecated]] - auto is_same_bound_identifier(const_reference x, const_reference y) const -> bool - { - let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; - let const& renamed_y = y.is() ? notate(y, syntactic_environment()) : y; - - return renamed_x.is_also() and renamed_x.as().is_bound() and - renamed_y.is_also() and renamed_y.as().is_bound() and eq(renamed_x, renamed_y); - }; - - [[deprecated]] - auto is_same_free_identifier(const_reference x, const_reference y) -> bool - { - let const& renamed_x = x.is() ? notate(x, syntactic_environment()) : x; - let const& renamed_y = y.is() ? notate(y, syntactic_environment()) : y; - - return renamed_x.is_also() and renamed_x.as().is_free() and - renamed_y.is_also() and renamed_y.as().is_free() and eq(renamed_x, renamed_y); - } - auto reserve(const_reference x) -> const_reference { assert(is_identifier(x)); diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 659c78245..08f47a763 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2047,7 +2047,7 @@ namespace meevax // define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) // { - // return current_environment.is_same_bound_identifier(car(xs), cadr(xs)); + // return f; // }); /* ------------------------------------------------------------------------- From 2f71238212b75d51172f51786c7a4df3c7ffc657 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 26 Apr 2022 01:54:28 +0900 Subject: [PATCH 115/118] Remove struct `generic_macro_transformer` Signed-off-by: yamacir-kit --- README.md | 6 +++--- VERSION | 2 +- include/meevax/kernel/machine.hpp | 21 ++++++--------------- src/kernel/environment.cpp | 2 +- 4 files changed, 11 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 137eb3037..6f124b7b9 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.944.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.945.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.944_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.945_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.944 +Meevax Lisp System, version 0.3.945 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index f2ba09434..2b6dce9f4 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.944 +0.3.945 diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 764edb7fb..677096994 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -61,7 +61,7 @@ inline namespace kernel assert(expression.is()); } - virtual auto expand(const_reference, const_reference) -> object = 0; /* -- + auto expand(const_reference form, const_reference use_env) /* ------------ * * Scheme programs can define and use new derived expression types, * called macros. Program-defined expression types have the syntax @@ -91,22 +91,13 @@ inline namespace kernel * environment::evaluate. * * --------------------------------------------------------------------- */ - }; - - struct generic_macro_transformer : public transformer - { - using transformer::expression; - using transformer::mac_env; - using transformer::transformer; - - auto expand(const_reference form, const_reference use_env) -> object override { return mac_env.template as().apply(expression, list(form, use_env, mac_env)); } - friend auto operator <<(std::ostream & os, generic_macro_transformer const& datum) -> std::ostream & + friend auto operator <<(std::ostream & os, transformer const& datum) -> std::ostream & { - return os << magenta("#,(") << green("generic-macro-transformer ") << faint("#;", &datum) << magenta(")"); + return os << magenta("#,(") << green("transformer ") << faint("#;", &datum) << magenta(")"); } }; @@ -180,7 +171,7 @@ inline namespace kernel * * --------------------------------------------------------------------- */ { - if (current_expression.is() or current_expression.is_also()) + if (current_expression.is()) { let const& n = current_environment.notate(current_expression, current_syntactic_environment); @@ -416,7 +407,7 @@ inline namespace kernel * * ------------------------------------------------------------------- */ assert(car(s).template is()); - cadr(c).template as().strip() = make(car(s), static_cast(*this).fork(unit)); + cadr(c).template as().strip() = make(car(s), static_cast(*this).fork(unit)); c = cddr(c); goto decode; @@ -435,7 +426,7 @@ inline namespace kernel let const& f = environment(static_cast(*this)).execute(binding); - binding = make(f, static_cast(*this).fork(unit)); + binding = make(f, static_cast(*this).fork(unit)); } }(); diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index a67658a78..d20d2ee0b 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -130,7 +130,7 @@ inline namespace kernel auto environment::is_identifier(const_reference x) -> bool { - return x.is() or x.is_also() or x.is(); + return x.is() or x.is(); } auto environment::load(std::string const& s) -> object From fd76951d5812641cc4359379bd9579c0070bab77 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 26 Apr 2022 02:25:45 +0900 Subject: [PATCH 116/118] Rename member variable `syntactic_environment` to `scope` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 12 +- include/meevax/kernel/environment.hpp | 8 +- include/meevax/kernel/machine.hpp | 128 +++++++++--------- .../meevax/kernel/syntactic_continuation.hpp | 2 +- include/meevax/kernel/syntax.hpp | 2 +- src/kernel/environment.cpp | 18 +-- src/library/meevax.cpp | 6 +- 9 files changed, 90 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 6f124b7b9..ccd548765 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.945.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.946.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.945_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.946_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.945 +Meevax Lisp System, version 0.3.946 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 2b6dce9f4..be202f1ed 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.945 +0.3.946 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index fbbcf5aa4..e83c182bf 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -205,13 +205,13 @@ inline namespace kernel if (auto const& [name, perform] = *iter; std::next(current_short_option) != std::end(current_short_options)) { return perform(read(std::string(std::next(current_short_option), std::end(current_short_options))), - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { return perform(read(*current_option), - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else @@ -222,7 +222,7 @@ inline namespace kernel else if (auto iter = short_options.find(*current_short_option); iter != std::end(short_options)) { cdr(*iter)(unit, - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else @@ -238,13 +238,13 @@ inline namespace kernel if (analysis.length(2)) // argument part { return cdr(*iter)(read(analysis.str(3)), - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { return cdr(*iter)(read(*current_option), - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else @@ -255,7 +255,7 @@ inline namespace kernel else if (auto iter = long_options.find(current_long_option); iter != std::end(long_options)) { return cdr(*iter)(unit, - static_cast(*this).syntactic_environment(), + static_cast(*this).scope(), static_cast(*this)); } else diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index 091f39adc..e9a0c7d2e 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -79,10 +79,10 @@ inline namespace kernel auto execute(const_reference) -> object; - auto fork(const_reference syntactic_environment) const + auto fork(const_reference scope) const { let const copy = make(*this); - copy.as().syntactic_environment() = syntactic_environment; + copy.as().scope() = scope; return copy; } @@ -119,9 +119,9 @@ inline namespace kernel auto load(std::string const&) -> object; - auto syntactic_environment() const noexcept -> const_reference; + auto scope() const noexcept -> const_reference; - auto syntactic_environment() noexcept -> reference; + auto scope() noexcept -> reference; auto notate(const_reference, const_reference) -> object; diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 677096994..95c3ae852 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -40,7 +40,7 @@ inline namespace kernel {} IMPORT(environment, global_environment, const); - IMPORT(environment, syntactic_environment, ); + IMPORT(environment, scope, ); protected: let s, // stack (holding intermediate results and return address) @@ -111,7 +111,7 @@ inline namespace kernel auto notate() { - return enclosure.as().notate(expression, enclosure.as().syntactic_environment()); + return enclosure.as().notate(expression, enclosure.as().scope()); } friend auto operator <<(std::ostream & os, syntactic_closure const& datum) -> std::ostream & @@ -146,7 +146,7 @@ inline namespace kernel context const current_context, environment & current_environment, const_reference current_expression, - const_reference current_syntactic_environment = unit, + const_reference current_scope = unit, const_reference current_continuation = list(make(mnemonic::stop))) -> object { if (current_expression.is()) /* ------------------------------------ @@ -173,15 +173,14 @@ inline namespace kernel { if (current_expression.is()) { - let const& n = current_environment.notate(current_expression, - current_syntactic_environment); + let const& n = current_environment.notate(current_expression, current_scope); return cons(n.as().make_load_instruction(), n, current_continuation); } else if (current_expression.is()) { - if (let const& n = std::as_const(current_environment).notate(current_expression, current_syntactic_environment); select(n)) + if (let const& n = std::as_const(current_environment).notate(current_expression, current_scope); select(n)) { return cons(n.as().make_load_instruction(), n, current_continuation); @@ -191,7 +190,7 @@ inline namespace kernel return compile(current_context, current_expression.as().enclosure.template as(), current_expression.as().expression, - current_expression.as().enclosure.template as().syntactic_environment(), + current_expression.as().enclosure.template as().scope(), current_continuation); } } @@ -201,15 +200,14 @@ inline namespace kernel current_continuation); } } - else if (let const& notation = std::as_const(current_environment).notate(car(current_expression), current_syntactic_environment); notation.is()) + else if (let const& notation = std::as_const(current_environment).notate(car(current_expression), current_scope); notation.is()) { assert(notation.as().strip().is_also()); return compile(context::none, current_environment, - notation.as().strip().as().expand(current_expression, - current_environment.fork(current_syntactic_environment)), - current_syntactic_environment, + notation.as().strip().as().expand(current_expression, current_environment.fork(current_scope)), + current_scope, current_continuation); } else if (let const& applicant = notation.is() ? notation.as().strip() : car(current_expression); applicant.is_also()) @@ -217,7 +215,7 @@ inline namespace kernel return applicant.as().compile(current_context, current_environment, cdr(current_expression), - current_syntactic_environment, + current_scope, current_continuation); } else if (applicant.is_also()) @@ -225,8 +223,8 @@ inline namespace kernel return compile(context::none, current_environment, applicant.as().expand(current_expression, - current_environment.fork(current_syntactic_environment)), - current_syntactic_environment, + current_environment.fork(current_scope)), + current_scope, current_continuation); } else /* ------------------------------------------------------------------ @@ -269,12 +267,12 @@ inline namespace kernel return operand(context::none, current_environment, cdr(current_expression), - current_syntactic_environment, + current_scope, compile(context::none, current_environment, car(current_expression), - current_syntactic_environment, - cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_syntactic_environment, + current_scope, + cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_scope, current_continuation))); } } @@ -418,9 +416,7 @@ inline namespace kernel * ------------------------------------------------------------------- */ [&]() { - let const& syntactic_environment = cadr(c).template as().syntactic_environment(); - - for (let const& keyword_ : car(syntactic_environment)) + for (let const& keyword_ : car(cadr(c).template as().scope())) { let & binding = keyword_.as().strip(); @@ -434,7 +430,7 @@ inline namespace kernel body(context::none, static_cast(*this), cadr(c).template as().expression(), - cadr(c).template as().syntactic_environment(), + cadr(c).template as().scope(), cddr(c) ).template as()); @@ -456,14 +452,14 @@ inline namespace kernel env.execute(compile(context::outermost, env, cons(make("define-syntax", define_syntax), transformer_spec), - cadr(c).template as().syntactic_environment())); + cadr(c).template as().scope())); } std::swap(c.as(), machine::body(context::outermost, env, body, - cadr(c).template as().syntactic_environment(), + cadr(c).template as().scope(), cddr(c) ).template as()); }(); @@ -642,9 +638,9 @@ inline namespace kernel } } - static auto notate(const_reference variable, const_reference syntactic_environment) -> object + static auto notate(const_reference variable, const_reference scope) -> object { - for (auto outer = std::begin(syntactic_environment); outer != std::end(syntactic_environment); ++outer) + for (auto outer = std::begin(scope); outer != std::end(scope); ++outer) { for (auto inner = std::begin(*outer); inner != std::end(*outer); ++inner) { @@ -658,7 +654,7 @@ inline namespace kernel static_assert(std::is_base_of::value); return make(variable, - make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(scope), outer)), make(std::distance(std::begin(*outer), inner))); } else if (inner.is() and eq(inner, variable)) @@ -667,7 +663,7 @@ inline namespace kernel static_assert(std::is_base_of::value); return make(variable, - make(std::distance(std::begin(syntactic_environment), outer)), + make(std::distance(std::begin(scope), outer)), make(std::distance(std::begin(*outer), inner))); } } @@ -697,12 +693,12 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - let const& notation = current_environment.notate(car(current_expression), current_syntactic_environment); + let const& notation = current_environment.notate(car(current_expression), current_scope); return compile(context::none, current_environment, cadr(current_expression), - current_syntactic_environment, + current_scope, cons(notation.as().make_store_instruction(), notation, current_continuation)); } @@ -713,7 +709,7 @@ inline namespace kernel { if (form.is()) { - if (let const& notation = std::as_const(current_environment).notate(car(form), current_syntactic_environment); notation.is()) + if (let const& notation = std::as_const(current_environment).notate(car(form), current_scope); notation.is()) { if (let const& callee = notation.as().strip(); callee.is()) { @@ -763,7 +759,7 @@ inline namespace kernel return compile(current_context | context::tail, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, current_continuation); } else if (auto const& [binding_specs, body] = sweep(current_expression); binding_specs) @@ -781,7 +777,7 @@ inline namespace kernel unzip1(binding_specs), append(map(curry(cons)(make("set!", set)), binding_specs), body)), make_list(length(binding_specs), undefined_object)), - current_syntactic_environment, + current_scope, current_continuation); } else @@ -789,12 +785,12 @@ inline namespace kernel return compile(current_context, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, cons(make(mnemonic::drop), begin(current_context, current_environment, cdr(current_expression), - current_syntactic_environment, + current_scope, current_continuation))); } } @@ -811,8 +807,8 @@ inline namespace kernel compile(current_context, current_environment, car(current_expression), - current_syntactic_environment, - cons(make(mnemonic::call), current_syntactic_environment, + current_scope, + cons(make(mnemonic::call), current_scope, current_continuation))); } @@ -838,7 +834,7 @@ inline namespace kernel compile(context::tail, current_environment, cadr(current_expression), - current_syntactic_environment, + current_scope, list(make(mnemonic::return_))); auto alternate = @@ -846,7 +842,7 @@ inline namespace kernel ? compile(context::tail, current_environment, caddr(current_expression), - current_syntactic_environment, + current_scope, list(make(mnemonic::return_))) : list(make(mnemonic::load_constant), unspecified_object, make(mnemonic::return_)); @@ -854,7 +850,7 @@ inline namespace kernel return compile(context::none, current_environment, car(current_expression), // - current_syntactic_environment, + current_scope, cons(make(mnemonic::tail_select), consequent, alternate, cdr(current_continuation))); } @@ -864,7 +860,7 @@ inline namespace kernel compile(context::none, current_environment, cadr(current_expression), - current_syntactic_environment, + current_scope, list(make(mnemonic::join))); auto alternate = @@ -872,7 +868,7 @@ inline namespace kernel ? compile(context::none, current_environment, caddr(current_expression), - current_syntactic_environment, + current_scope, list(make(mnemonic::join))) : list(make(mnemonic::load_constant), unspecified_object, make(mnemonic::join)); @@ -880,7 +876,7 @@ inline namespace kernel return compile(context::none, current_environment, car(current_expression), // - current_syntactic_environment, + current_scope, cons(make(mnemonic::select), consequent, alternate, current_continuation)); } @@ -891,11 +887,11 @@ inline namespace kernel return compile(context::none, current_environment, cadr(current_expression), - current_syntactic_environment, + current_scope, compile(context::none, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, cons(make(mnemonic::cons), current_continuation))); } @@ -924,15 +920,15 @@ inline namespace kernel * * ----------------------------------------------------------------------- */ { - if (current_syntactic_environment.is() or (current_context & context::outermost)) + if (current_scope.is() or (current_context & context::outermost)) { if (car(current_expression).is()) // (define (f . ) ) { return compile(context::none, current_environment, cons(make("lambda", lambda), cdar(current_expression), cdr(current_expression)), - current_syntactic_environment, - cons(make(mnemonic::define), current_environment.notate(caar(current_expression), current_syntactic_environment), + current_scope, + cons(make(mnemonic::define), current_environment.notate(caar(current_expression), current_scope), current_continuation)); } else // (define x ...) @@ -940,8 +936,8 @@ inline namespace kernel return compile(context::none, current_environment, cdr(current_expression) ? cadr(current_expression) : unspecified_object, - current_syntactic_environment, - cons(make(mnemonic::define), current_environment.notate(car(current_expression), current_syntactic_environment), + current_scope, + cons(make(mnemonic::define), current_environment.notate(car(current_expression), current_scope), current_continuation)); } } @@ -1008,8 +1004,8 @@ inline namespace kernel return compile(context::none, current_environment, cdr(current_expression) ? cadr(current_expression) : unspecified_object, - current_syntactic_environment, - cons(make(mnemonic::define_syntax), current_environment.notate(car(current_expression), current_syntactic_environment), + current_scope, + cons(make(mnemonic::define_syntax), current_environment.notate(car(current_expression), current_scope), current_continuation)); } @@ -1041,7 +1037,7 @@ inline namespace kernel body(current_context, current_environment, cdr(current_expression), - cons(car(current_expression), current_syntactic_environment), // Extend lexical environment. + cons(car(current_expression), current_scope), // Extend lexical scope. list(make(mnemonic::return_))), current_continuation); } @@ -1072,7 +1068,7 @@ inline namespace kernel compile(context::outermost, current_environment, cadr(binding), - current_syntactic_environment)); + current_scope)); }; auto const [bindings, body] = unpair(current_expression); @@ -1080,7 +1076,7 @@ inline namespace kernel return cons(make(mnemonic::let_syntax), make(body, cons(map(make_keyword, bindings), - current_syntactic_environment)), + current_scope)), current_continuation); } @@ -1101,7 +1097,7 @@ inline namespace kernel * ----------------------------------------------------------------------- */ { return cons(make(mnemonic::letrec_syntax), - make(current_expression, current_syntactic_environment), + make(current_expression, current_scope), current_continuation); } @@ -1153,11 +1149,11 @@ inline namespace kernel operand(context::none, current_environment, inits, - cons(variables, current_syntactic_environment), + cons(variables, current_scope), lambda(context::none, current_environment, cons(variables, cdr(current_expression)), // ( ) - current_syntactic_environment, + current_scope, cons(make(mnemonic::letrec), current_continuation)))); } @@ -1208,11 +1204,11 @@ inline namespace kernel return operand(context::none, current_environment, cdr(current_expression), - current_syntactic_environment, + current_scope, compile(context::none, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, cons(make(mnemonic::cons), current_continuation))); } @@ -1221,7 +1217,7 @@ inline namespace kernel return compile(context::none, current_environment, current_expression, - current_syntactic_environment, + current_scope, current_continuation); } } @@ -1259,7 +1255,7 @@ inline namespace kernel return compile(current_context, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, current_continuation); } else @@ -1267,12 +1263,12 @@ inline namespace kernel return compile(context::outermost, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, cons(make(mnemonic::drop), begin(context::outermost, current_environment, cdr(current_expression), - current_syntactic_environment, + current_scope, current_continuation))); } } @@ -1283,7 +1279,7 @@ inline namespace kernel return compile(current_context, current_environment, car(current_expression), - current_syntactic_environment, + current_scope, current_continuation); } else @@ -1291,12 +1287,12 @@ inline namespace kernel return compile(context::none, current_environment, car(current_expression), // head expression - current_syntactic_environment, + current_scope, cons(make(mnemonic::drop), // pop result of head expression begin(context::none, current_environment, cdr(current_expression), // rest expressions - current_syntactic_environment, + current_scope, current_continuation))); } } diff --git a/include/meevax/kernel/syntactic_continuation.hpp b/include/meevax/kernel/syntactic_continuation.hpp index 6dad5224a..64955d845 100644 --- a/include/meevax/kernel/syntactic_continuation.hpp +++ b/include/meevax/kernel/syntactic_continuation.hpp @@ -32,7 +32,7 @@ inline namespace kernel return first; } - auto syntactic_environment() const -> const_reference + auto scope() const -> const_reference { return second; } diff --git a/include/meevax/kernel/syntax.hpp b/include/meevax/kernel/syntax.hpp index 28cc51054..3c2467201 100644 --- a/include/meevax/kernel/syntax.hpp +++ b/include/meevax/kernel/syntax.hpp @@ -26,7 +26,7 @@ [[maybe_unused]] context const current_context, \ [[maybe_unused]] environment & current_environment, \ [[maybe_unused]] const_reference current_expression, \ - [[maybe_unused]] const_reference current_syntactic_environment, \ + [[maybe_unused]] const_reference current_scope, \ [[maybe_unused]] const_reference current_continuation) -> object namespace meevax diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index d20d2ee0b..86ed7253f 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -22,7 +22,7 @@ inline namespace kernel { auto environment::operator [](const_reference name) -> const_reference { - return notate(name, syntactic_environment()).as().strip(); + return notate(name, scope()).as().strip(); } auto environment::operator [](std::string const& name) -> const_reference @@ -34,7 +34,7 @@ inline namespace kernel { auto dump = std::make_tuple(std::exchange(s, list(f, xs)), std::exchange(e, unit), - std::exchange(c, list(make(mnemonic::call), syntactic_environment(), + std::exchange(c, list(make(mnemonic::call), scope(), make(mnemonic::stop))), std::exchange(d, unit)); @@ -72,7 +72,7 @@ inline namespace kernel { auto dump = std::make_tuple(std::exchange(s, unit), std::exchange(e, unit), - std::exchange(c, compile(context::none, *this, expression, syntactic_environment())), + std::exchange(c, compile(context::none, *this, expression, scope())), std::exchange(d, unit)); if (is_debug_mode()) @@ -150,23 +150,23 @@ inline namespace kernel } } - auto environment::syntactic_environment() const noexcept -> const_reference + auto environment::scope() const noexcept -> const_reference { return first; } - auto environment::syntactic_environment() noexcept -> reference + auto environment::scope() noexcept -> reference { return first; } - auto environment::notate(const_reference variable, const_reference syntactic_environment) const -> object + auto environment::notate(const_reference variable, const_reference scope) const -> object { if (not is_identifier(variable)) { return f; } - else if (let const& notation = machine::notate(variable, syntactic_environment); select(notation)) + else if (let const& notation = machine::notate(variable, scope); select(notation)) { return notation; } @@ -176,13 +176,13 @@ inline namespace kernel } } - auto environment::notate(const_reference variable, const_reference syntactic_environment) -> object + auto environment::notate(const_reference variable, const_reference scope) -> object { if (not is_identifier(variable)) { return f; } - if (let const& notation = std::as_const(*this).notate(variable, syntactic_environment); select(notation)) + if (let const& notation = std::as_const(*this).notate(variable, scope); select(notation)) { return notation; } diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index 08f47a763..ee5111744 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2119,11 +2119,11 @@ namespace meevax return car(xs).is_also(); }); - define("macroexpand-1", [](let const& xs, let const& current_syntactic_environment, environment & current_environment) + define("macroexpand-1", [](let const& xs, let const& current_scope, environment & current_environment) { - if (let const& macro = current_environment.notate(caar(xs), current_syntactic_environment).as().strip(current_environment.e); macro.is_also()) + if (let const& macro = current_environment.notate(caar(xs), current_scope).as().strip(current_environment.e); macro.is_also()) { - return macro.as().expand(car(xs), current_environment.fork(current_syntactic_environment)); + return macro.as().expand(car(xs), current_environment.fork(current_scope)); } else { From 729b677db322435d21f6e3f120ed12bef1d71856 Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 26 Apr 2022 02:43:44 +0900 Subject: [PATCH 117/118] Remove procedure `generate-identifier` and `macroexpand-1` Signed-off-by: yamacir-kit --- README.md | 6 ++-- VERSION | 2 +- include/meevax/kernel/environment.hpp | 5 --- src/library/meevax.cpp | 51 +-------------------------- 4 files changed, 5 insertions(+), 59 deletions(-) diff --git a/README.md b/README.md index ccd548765..c19a737a1 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.946.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.947.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.946_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.947_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.946 +Meevax Lisp System, version 0.3.947 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index be202f1ed..9ab401b37 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.946 +0.3.947 diff --git a/include/meevax/kernel/environment.hpp b/include/meevax/kernel/environment.hpp index e9a0c7d2e..afb480712 100644 --- a/include/meevax/kernel/environment.hpp +++ b/include/meevax/kernel/environment.hpp @@ -101,11 +101,6 @@ inline namespace kernel return car(global_environment()); } - auto generate_free_identifier(const_reference x) -> object - { - return x; // TODO - } - auto global_environment() noexcept -> reference; auto global_environment() const noexcept -> const_reference; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index ee5111744..d5973b33c 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -2045,7 +2045,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - // define("bound-identifier=?", [](let const& xs, let const&, auto && current_environment) + // define("bound-identifier=?", [](let const& xs, auto&&...) // { // return f; // }); @@ -2077,60 +2077,11 @@ namespace meevax } }); - /* ------------------------------------------------------------------------- - * - * (generate-identifier) procedure - * (generate-identifier symbol) procedure - * - * Returns a new identifier. The optional argument to generate-identifier - * specifies the symbolic name of the resulting identifier. If no argument - * is supplied the name is unspecified. - * - * Generate-identifier is used to introduce bound identifiers into the - * output of a transformer. Since introduced bound identifiers are - * automatically renamed, generate-identifier is necessary only for - * distinguishing introduced identifiers when an indefinite number of them - * must be generated by a macro. - * - * The optional argument to generate-identifier specifies the symbolic - * name of the resulting identifier. If no argument is supplied the name - * is unspecified. The procedure identifier->symbol reveals the symbolic - * name of an identifier. - * - * ---------------------------------------------------------------------- */ - - define("generate-identifier", [](let const& xs, let const&, auto && current_environment) - { - switch (length(xs)) - { - case 0: - return current_environment.generate_free_identifier(make()); - - case 1: - return current_environment.generate_free_identifier(car(xs)); - - default: - throw invalid_application(intern("generate-identifier") | xs); - } - }); - define("transformer?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); - define("macroexpand-1", [](let const& xs, let const& current_scope, environment & current_environment) - { - if (let const& macro = current_environment.notate(caar(xs), current_scope).as().strip(current_environment.e); macro.is_also()) - { - return macro.as().expand(car(xs), current_environment.fork(current_scope)); - } - else - { - throw error(make("not a macro"), caar(xs)); - } - }); - define("disassemble", [](let const& xs, auto&&...) { if (0 < length(xs)) From 5ef5cbb0fb20fc7a887af9754f61a7a569f53fad Mon Sep 17 00:00:00 2001 From: yamacir-kit Date: Tue, 26 Apr 2022 03:07:08 +0900 Subject: [PATCH 118/118] Remove unused arguments from `procedure::call` Signed-off-by: yamacir-kit --- README.md | 6 +- VERSION | 2 +- include/meevax/kernel/configurator.hpp | 24 +- include/meevax/kernel/machine.hpp | 26 +-- include/meevax/kernel/procedure.hpp | 4 +- src/kernel/environment.cpp | 2 +- src/kernel/instruction.cpp | 4 +- src/library/meevax.cpp | 306 ++++++++++++------------- test/vector.cpp | 2 +- 9 files changed, 181 insertions(+), 195 deletions(-) diff --git a/README.md b/README.md index c19a737a1..6001b9755 100644 --- a/README.md +++ b/README.md @@ -100,9 +100,9 @@ sudo rm -rf /usr/local/share/meevax | Target Name | Description |:-------------------|:-- -| `all` (default) | Build shared-library `libmeevax.0.3.947.so` and executable `meevax`. +| `all` (default) | Build shared-library `libmeevax.0.3.948.so` and executable `meevax`. | `test` | Test executable `meevax`. -| `package` | Generate debian package `meevax_0.3.947_amd64.deb`. +| `package` | Generate debian package `meevax_0.3.948_amd64.deb`. | `install` | Copy files into `/usr/local` __(1)__. | `install.deb` | `all` + `package` + `sudo apt install .deb` | `safe-install.deb` | `all` + `test` + `package` + `sudo apt install .deb` @@ -117,7 +117,7 @@ __(1)__ Meevax installed by `make install` cannot be uninstalled by the system's ## Usage ``` -Meevax Lisp System, version 0.3.947 +Meevax Lisp System, version 0.3.948 Usage: meevax [OPTION...] [FILE...] diff --git a/VERSION b/VERSION index 9ab401b37..a417c4cf1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3.947 +0.3.948 diff --git a/include/meevax/kernel/configurator.hpp b/include/meevax/kernel/configurator.hpp index e83c182bf..1d4546d06 100644 --- a/include/meevax/kernel/configurator.hpp +++ b/include/meevax/kernel/configurator.hpp @@ -204,15 +204,11 @@ inline namespace kernel { if (auto const& [name, perform] = *iter; std::next(current_short_option) != std::end(current_short_options)) { - return perform(read(std::string(std::next(current_short_option), std::end(current_short_options))), - static_cast(*this).scope(), - static_cast(*this)); + return perform(read(std::string(std::next(current_short_option), std::end(current_short_options)))); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { - return perform(read(*current_option), - static_cast(*this).scope(), - static_cast(*this)); + return perform(read(*current_option)); } else { @@ -221,9 +217,7 @@ inline namespace kernel } else if (auto iter = short_options.find(*current_short_option); iter != std::end(short_options)) { - cdr(*iter)(unit, - static_cast(*this).scope(), - static_cast(*this)); + cdr(*iter)(unit); } else { @@ -237,15 +231,11 @@ inline namespace kernel { if (analysis.length(2)) // argument part { - return cdr(*iter)(read(analysis.str(3)), - static_cast(*this).scope(), - static_cast(*this)); + return cdr(*iter)(read(analysis.str(3))); } else if (++current_option != std::end(args) and not std::regex_match(*current_option, analysis, pattern)) { - return cdr(*iter)(read(*current_option), - static_cast(*this).scope(), - static_cast(*this)); + return cdr(*iter)(read(*current_option)); } else { @@ -254,9 +244,7 @@ inline namespace kernel } else if (auto iter = long_options.find(current_long_option); iter != std::end(long_options)) { - return cdr(*iter)(unit, - static_cast(*this).scope(), - static_cast(*this)); + return cdr(*iter)(unit); } else { diff --git a/include/meevax/kernel/machine.hpp b/include/meevax/kernel/machine.hpp index 95c3ae852..7856930df 100644 --- a/include/meevax/kernel/machine.hpp +++ b/include/meevax/kernel/machine.hpp @@ -272,7 +272,7 @@ inline namespace kernel current_environment, car(current_expression), current_scope, - cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_scope, + cons(make(current_context & context::tail ? mnemonic::tail_call : mnemonic::call), current_continuation))); } } @@ -468,31 +468,31 @@ inline namespace kernel case mnemonic::call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) + * ( xs . s) e (%call . c) d => () (xs . e') c' (s e c . d) * * where = (c' . e') * * ------------------------------------------------------------------- */ { - d = cons(cddr(s), e, cddr(c), d); + d = cons(cddr(s), e, cdr(c), d); c = callee.as().c(); e = cons(cadr(s), callee.as().e()); s = unit; } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%call . c) d => (x . s) e c d + * ( xs . s) e (%call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().call(cadr(s), cadr(c), static_cast(*this)), cddr(s)); - c = cddr(c); + s = cons(callee.as().call(cadr(s)), cddr(s)); + c = cdr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -512,7 +512,7 @@ inline namespace kernel case mnemonic::tail_call: if (let const& callee = car(s); callee.is()) /* --------------- * - * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d + * ( xs . s) e (%tail-call . c) d => () (xs . e') c' d * * where = (c' . e') * @@ -524,18 +524,18 @@ inline namespace kernel } else if (callee.is_also()) /* ------------------------------- * - * ( xs . s) e (%tail-call . c) d => (x . s) e c d + * ( xs . s) e (%tail-call . c) d => (x . s) e c d * * where x = procedure(xs) * * ------------------------------------------------------------------- */ { - s = cons(callee.as().call(cadr(s), cadr(c), static_cast(*this)), cddr(s)); - c = cddr(c); + s = cons(callee.as().call(cadr(s)), cddr(s)); + c = cdr(c); } else if (callee.is()) /* --------------------------------- * - * ( xs . s) e (%tail-call . c) d => (xs . s') e' c' d' + * ( xs . s) e (%tail-call . c) d => (xs . s') e' c' d' * * where = (s' e' c' . 'd) * @@ -808,7 +808,7 @@ inline namespace kernel current_environment, car(current_expression), current_scope, - cons(make(mnemonic::call), current_scope, + cons(make(mnemonic::call), current_continuation))); } diff --git a/include/meevax/kernel/procedure.hpp b/include/meevax/kernel/procedure.hpp index d70f77718..ac8045566 100644 --- a/include/meevax/kernel/procedure.hpp +++ b/include/meevax/kernel/procedure.hpp @@ -24,9 +24,7 @@ namespace meevax { inline namespace kernel { - #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs, \ - meevax::const_reference, \ - environment &) + #define PROCEDURE(...) meevax::object __VA_ARGS__(meevax::const_reference xs) struct procedure : public description { diff --git a/src/kernel/environment.cpp b/src/kernel/environment.cpp index 86ed7253f..e49031f55 100644 --- a/src/kernel/environment.cpp +++ b/src/kernel/environment.cpp @@ -34,7 +34,7 @@ inline namespace kernel { auto dump = std::make_tuple(std::exchange(s, list(f, xs)), std::exchange(e, unit), - std::exchange(c, list(make(mnemonic::call), scope(), + std::exchange(c, list(make(mnemonic::call), make(mnemonic::stop))), std::exchange(d, unit)); diff --git a/src/kernel/instruction.cpp b/src/kernel/instruction.cpp index 5799f97af..723eae745 100644 --- a/src/kernel/instruction.cpp +++ b/src/kernel/instruction.cpp @@ -84,6 +84,7 @@ inline namespace kernel switch ((*iter).as().value) { + case mnemonic::call: case mnemonic::cons: case mnemonic::drop: case mnemonic::dummy: @@ -91,11 +92,11 @@ inline namespace kernel case mnemonic::letrec: case mnemonic::return_: case mnemonic::stop: + case mnemonic::tail_call: os << *iter << "\n"; ++offset; break; - case mnemonic::call: case mnemonic::define: case mnemonic::define_syntax: case mnemonic::let_syntax: @@ -107,7 +108,6 @@ inline namespace kernel case mnemonic::store_absolute: case mnemonic::store_relative: case mnemonic::store_variadic: - case mnemonic::tail_call: os << *iter << " " << *++iter << "\n"; offset += 2; break; diff --git a/src/library/meevax.cpp b/src/library/meevax.cpp index d5973b33c..b2f4f6d89 100644 --- a/src/library/meevax.cpp +++ b/src/library/meevax.cpp @@ -48,7 +48,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eqv?", [](let const& xs, auto&&...) // TODO Rename to value=? + define("eqv?", [](let const& xs) // TODO Rename to value=? { return eqv(car(xs), cadr(xs)); }); @@ -72,7 +72,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eq?", [](auto&& xs, auto&&...) // TODO Rename to reference=? + define("eq?", [](auto&& xs) // TODO Rename to reference=? { return eq(car(xs), cadr(xs)); }); @@ -99,16 +99,16 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); - define("complex?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_complex (); }); - define("real?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_real (); }); - define("rational?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_rational(); }); - define("integer?", [](let const& xs, auto&&...) { return car(xs).is_also() and car(xs).as().is_integer (); }); + define("number?", [](let const& xs) { return car(xs).is_also(); }); + define("complex?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_complex (); }); + define("real?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_real (); }); + define("rational?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_rational(); }); + define("integer?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_integer (); }); - define("%complex?", [](let const& xs, auto&&...) { return car(xs).is(); }); - define("ratio?", [](let const& xs, auto&&...) { return car(xs).is(); }); - define("single-float?", [](let const& xs, auto&&...) { return car(xs).is(); }); - define("double-float?", [](let const& xs, auto&&...) { return car(xs).is(); }); + define("%complex?", [](let const& xs) { return car(xs).is(); }); + define("ratio?", [](let const& xs) { return car(xs).is(); }); + define("single-float?", [](let const& xs) { return car(xs).is(); }); + define("double-float?", [](let const& xs) { return car(xs).is(); }); /* ------------------------------------------------------------------------- * @@ -118,7 +118,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("exact-integer?", [](let const& xs, auto&&...) + define("exact-integer?", [](let const& xs) { return car(xs).is(); }); @@ -159,7 +159,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, COMPARE) \ - define(#SYMBOL, [](let const& xs, auto&&...) \ + define(#SYMBOL, [](let const& xs) \ { \ return std::adjacent_find( \ std::begin(xs), std::end(xs), [](let const& a, let const& b) \ @@ -186,8 +186,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("+", [](let const& xs, auto&&...) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); - define("*", [](let const& xs, auto&&...) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); + define("+", [](let const& xs) { return std::accumulate(std::begin(xs), std::end(xs), e0, [](let const& a, let const& b) { return a + b; }); }); + define("*", [](let const& xs) { return std::accumulate(std::begin(xs), std::end(xs), e1, [](let const& a, let const& b) { return a * b; }); }); /* ------------------------------------------------------------------------- * @@ -208,7 +208,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define DEFINE(SYMBOL, FUNCTION, BASIS) \ - define(SYMBOL, [](let const& xs, auto&&...) \ + define(SYMBOL, [](let const& xs) \ { \ switch (length(xs)) \ { \ @@ -250,10 +250,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("floor", [](let const& xs, auto&&...) { return car(xs).as().floor(); }); - define("ceiling", [](let const& xs, auto&&...) { return car(xs).as().ceil(); }); - define("truncate", [](let const& xs, auto&&...) { return car(xs).as().trunc(); }); - define("round", [](let const& xs, auto&&...) { return car(xs).as().round(); }); + define("floor", [](let const& xs) { return car(xs).as().floor(); }); + define("ceiling", [](let const& xs) { return car(xs).as().ceil(); }); + define("truncate", [](let const& xs) { return car(xs).as().trunc(); }); + define("round", [](let const& xs) { return car(xs).as().round(); }); /* ------------------------------------------------------------------------- * @@ -268,7 +268,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("expt", [](let const& xs, auto&&...) + define("expt", [](let const& xs) { return car(xs).as().pow(cadr(xs)); }); @@ -309,8 +309,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "exact", [](let const& xs, auto&&...) { return car(xs).as().exact (); }); - define("inexact", [](let const& xs, auto&&...) { return car(xs).as().inexact(); }); + define( "exact", [](let const& xs) { return car(xs).as().exact (); }); + define("inexact", [](let const& xs) { return car(xs).as().inexact(); }); /* ------------------------------------------------------------------------- * @@ -349,7 +349,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("number->string", [](auto&& xs, auto&&...) + define("number->string", [](auto&& xs) { return make(lexical_cast(car(xs))); }); @@ -371,7 +371,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->number", [](let const& xs, auto&&...) + define("string->number", [](let const& xs) { switch (length(xs)) { @@ -395,7 +395,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("pair?", [](let const& xs, auto&&...) + define("pair?", [](let const& xs) { return car(xs).is(); }); @@ -410,7 +410,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("cons", cons_, [](let const& xs, auto&&...) + define("cons", cons_, [](let const& xs) { return cons(car(xs), cadr(xs)); }); @@ -429,8 +429,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("car", [](let const& xs, auto&&...) { return caar(xs); }); - define("cdr", [](let const& xs, auto&&...) { return cdar(xs); }); + define("car", [](let const& xs) { return caar(xs); }); + define("cdr", [](let const& xs) { return cdar(xs); }); /* ------------------------------------------------------------------------- * @@ -444,8 +444,8 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("set-car!", [](auto&& xs, auto&&...) { return caar(xs) = cadr(xs); }); - define("set-cdr!", [](auto&& xs, auto&&...) { return cdar(xs) = cadr(xs); }); + define("set-car!", [](auto&& xs) { return caar(xs) = cadr(xs); }); + define("set-cdr!", [](auto&& xs) { return cdar(xs) = cadr(xs); }); /* ------------------------------------------------------------------------- * @@ -463,10 +463,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caar", [](let const& xs, auto&&...) { return caar(car(xs)); }); - define("cadr", [](let const& xs, auto&&...) { return cadr(car(xs)); }); - define("cdar", [](let const& xs, auto&&...) { return cdar(car(xs)); }); - define("cddr", [](let const& xs, auto&&...) { return cddr(car(xs)); }); + define("caar", [](let const& xs) { return caar(car(xs)); }); + define("cadr", [](let const& xs) { return cadr(car(xs)); }); + define("cdar", [](let const& xs) { return cdar(car(xs)); }); + define("cddr", [](let const& xs) { return cddr(car(xs)); }); /* ------------------------------------------------------------------------- * @@ -476,7 +476,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("null?", [](let const& xs, auto&&...) + define("null?", [](let const& xs) { return car(xs).is(); }); @@ -489,7 +489,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol?", [](let const& xs, auto&&...) + define("symbol?", [](let const& xs) { return car(xs).is(); }); @@ -504,7 +504,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("symbol->string", [](let const& xs, auto&&...) + define("symbol->string", [](let const& xs) { return make(car(xs).as()); }); @@ -519,7 +519,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->symbol", [](let const& xs, auto&&...) + define("string->symbol", [](let const& xs) { return intern(car(xs).as()); }); @@ -532,7 +532,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char?", [](let const& xs, auto&&...) + define("char?", [](let const& xs) { return car(xs).is(); }); @@ -554,7 +554,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("char->integer", [](let const& xs, auto&&...) + define("char->integer", [](let const& xs) { if (xs.is() and car(xs).is()) { @@ -566,7 +566,7 @@ namespace meevax } }); - define("integer->char", [](let const& xs, auto&&...) + define("integer->char", [](let const& xs) { if (xs.is() and car(xs).is()) { @@ -586,7 +586,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string?", [](let const& xs, auto&&...) + define("string?", [](let const& xs) { return car(xs).is(); }); @@ -602,7 +602,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-string", [](let const& xs, auto&&...) + define("make-string", [](let const& xs) { switch (length(xs)) { @@ -625,7 +625,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-length", [](let const& xs, auto&&...) + define("string-length", [](let const& xs) { return make(car(xs).as().size()); }); @@ -640,7 +640,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-ref", [](let const& xs, auto&&...) + define("string-ref", [](let const& xs) { return make(car(xs).as().at(static_cast(cadr(xs).as()))); }); @@ -663,7 +663,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-set!", [](let const& xs, auto&&...) + define("string-set!", [](let const& xs) { car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs).as(); return car(xs); @@ -705,7 +705,7 @@ namespace meevax * ---------------------------------------------------------------------- */ #define STRING_COMPARE(COMPARE) \ - [](let const& xs, auto&&...) \ + [](let const& xs) \ { \ return std::adjacent_find( \ std::begin(xs), std::end(xs), [](let const& a, let const& b) \ @@ -732,7 +732,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-append", [](let const& xs, auto&&...) + define("string-append", [](let const& xs) { string result; @@ -761,7 +761,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string->list", [](let const& xs, auto&&...) + define("string->list", [](let const& xs) { switch (length(xs)) { @@ -779,7 +779,7 @@ namespace meevax } }); - define("list->string", [](let const& xs, auto&&...) + define("list->string", [](let const& xs) { string s; @@ -802,7 +802,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("string-copy", [](let const& xs, auto&&...) + define("string-copy", [](let const& xs) { switch (length(xs)) { @@ -828,7 +828,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector?", [](let const& xs, auto&&...) + define("vector?", [](let const& xs) { return car(xs).is(); }); @@ -844,7 +844,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-vector", [](let const& xs, auto&&...) + define("make-vector", [](let const& xs) { switch (length(xs)) { @@ -868,7 +868,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector", [](let const& xs, auto&&...) + define("vector", [](let const& xs) { return make(for_each_in, xs); }); @@ -881,7 +881,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-length", [](let const& xs, auto&&...) + define("vector-length", [](let const& xs) { return make(car(xs).as().size()); }); @@ -895,7 +895,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-ref", [](let const& xs, auto&&...) + define("vector-ref", [](let const& xs) { return car(xs).as().at(static_cast(cadr(xs).as())); }); @@ -909,7 +909,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-set!", [](let const& xs, auto&&...) + define("vector-set!", [](let const& xs) { return car(xs).as().at(static_cast(cadr(xs).as())) = caddr(xs); }); @@ -929,7 +929,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->list", [](let const& xs, auto&&...) + define("vector->list", [](let const& xs) { switch (length(xs)) { @@ -947,7 +947,7 @@ namespace meevax } }); - define("list->vector", [](let const& xs, auto&&...) + define("list->vector", [](let const& xs) { return make(for_each_in, car(xs)); }); @@ -974,7 +974,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector->string", [](let const& xs, auto&&...) + define("vector->string", [](let const& xs) { switch (length(xs)) { @@ -1023,7 +1023,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("vector-fill!", [](let const& xs, auto&&...) + define("vector-fill!", [](let const& xs) { switch (length(xs)) { @@ -1054,17 +1054,17 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("closure?", [](let const& xs, auto&&...) + define("closure?", [](let const& xs) { return car(xs).is(); }); - define("continuation?", [](let const& xs, auto&&...) + define("continuation?", [](let const& xs) { return car(xs).is(); }); - define("foreign-function?", [](let const& xs, auto&&...) + define("foreign-function?", [](let const& xs) { return car(xs).is(); }); @@ -1082,7 +1082,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("default-exception-handler", [](let const& xs, auto&&...) -> object + define("default-exception-handler", [](let const& xs) -> object { throw car(xs); }); @@ -1103,7 +1103,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("make-error", [](let const& xs, auto&&...) + define("make-error", [](let const& xs) { return make(car(xs), cdr(xs)); }); @@ -1119,10 +1119,10 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "error?", [](let const& xs, auto&&...) { return car(xs).is< error>(); }); - define( "read-error?", [](let const& xs, auto&&...) { return car(xs).is< read_error>(); }); - define( "file-error?", [](let const& xs, auto&&...) { return car(xs).is< file_error>(); }); - define("syntax-error?", [](let const& xs, auto&&...) { return car(xs).is(); }); + define( "error?", [](let const& xs) { return car(xs).is< error>(); }); + define( "read-error?", [](let const& xs) { return car(xs).is< read_error>(); }); + define( "file-error?", [](let const& xs) { return car(xs).is< file_error>(); }); + define("syntax-error?", [](let const& xs) { return car(xs).is(); }); /* ------------------------------------------------------------------------- * @@ -1138,11 +1138,11 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define( "input-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); - define( "output-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); - define( "binary-port?", [](let const& , auto&&...) { return false; }); - define("textual-port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); - define( "port?", [](let const& xs, auto&&...) { return car(xs).is_also(); }); + define( "input-port?", [](let const& xs) { return car(xs).is_also(); }); + define( "output-port?", [](let const& xs) { return car(xs).is_also(); }); + define( "binary-port?", [](let const& ) { return false; }); + define("textual-port?", [](let const& xs) { return car(xs).is_also(); }); + define( "port?", [](let const& xs) { return car(xs).is_also(); }); /* ------------------------------------------------------------------------- * @@ -1154,7 +1154,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("input-port-open?", [](let const& xs, auto&&...) + define("input-port-open?", [](let const& xs) { if (let const& x = car(xs); x.is_also()) { @@ -1166,7 +1166,7 @@ namespace meevax } }); - define("output-port-open?", [](let const& xs, auto&&...) + define("output-port-open?", [](let const& xs) { if (let const& x = car(xs); x.is_also()) { @@ -1207,7 +1207,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-file", [](let const& xs, auto&&...) + define("open-input-file", [](let const& xs) { return make(car(xs).as()); }); @@ -1225,7 +1225,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-file", [](let const& xs, auto&&...) + define("open-output-file", [](let const& xs) { return make(car(xs).as()); }); @@ -1247,7 +1247,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("close-input-port", [](let const& xs, auto&&...) + define("close-input-port", [](let const& xs) { if (let const& x = car(xs); x.is_also()) { @@ -1257,7 +1257,7 @@ namespace meevax return unspecified_object; }); - define("close-output-port", [](let const& xs, auto&&...) + define("close-output-port", [](let const& xs) { if (let const& x = car(xs); x.is_also()) { @@ -1277,7 +1277,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-input-string", [](let const& xs, auto&&...) + define("open-input-string", [](let const& xs) { switch (length(xs)) { @@ -1301,7 +1301,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("open-output-string", [](let const& xs, auto&&...) + define("open-output-string", [](let const& xs) { switch (length(xs)) { @@ -1328,7 +1328,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("get-output-string", [](let const& xs, auto&&...) + define("get-output-string", [](let const& xs) { return make(car(xs).as().str()); }); @@ -1344,7 +1344,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-char", [](let const& xs, auto&&...) + define("%read-char", [](let const& xs) { try { @@ -1379,7 +1379,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%peek-char", [](let const& xs, auto&&...) + define("%peek-char", [](let const& xs) { try { @@ -1409,7 +1409,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eof-object?", [](let const& xs, auto&&...) + define("eof-object?", [](let const& xs) { return car(xs).is(); }); @@ -1447,7 +1447,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%char-ready?", [](let const& xs, auto&&...) + define("%char-ready?", [](let const& xs) { return static_cast(car(xs).as()); }); @@ -1464,7 +1464,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read-string", [](let const& xs, auto&&...) + define("%read-string", [](let const& xs) { switch (length(xs)) { @@ -1487,7 +1487,7 @@ namespace meevax * * --------------------------------------------------------------------- */ - define("put-char", [](let const& xs, auto&&...) + define("put-char", [](let const& xs) { cadr(xs).as() << static_cast(car(xs).as()); return unspecified_object; @@ -1505,7 +1505,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("put-string", [](let const& xs, auto&&...) + define("put-string", [](let const& xs) { switch (length(xs)) { @@ -1533,7 +1533,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%flush-output-port", [](let const& xs, auto&&...) + define("%flush-output-port", [](let const& xs) { car(xs).as() << std::flush; return unspecified_object; @@ -1572,7 +1572,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("digit-value", [](let const& xs, auto&&...) + define("digit-value", [](let const& xs) { if (auto c = car(xs).as(); std::isdigit(c.codepoint)) { @@ -1627,31 +1627,31 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("caaar", [](let const& xs, auto&&...) { return caaar(car(xs)); }); - define("caadr", [](let const& xs, auto&&...) { return caadr(car(xs)); }); - define("cadar", [](let const& xs, auto&&...) { return cadar(car(xs)); }); - define("caddr", [](let const& xs, auto&&...) { return caddr(car(xs)); }); - define("cdaar", [](let const& xs, auto&&...) { return cdaar(car(xs)); }); - define("cdadr", [](let const& xs, auto&&...) { return cdadr(car(xs)); }); - define("cddar", [](let const& xs, auto&&...) { return cddar(car(xs)); }); - define("cdddr", [](let const& xs, auto&&...) { return cdddr(car(xs)); }); - - define("caaaar", [](let const& xs, auto&&...) { return caaaar(car(xs)); }); - define("caaadr", [](let const& xs, auto&&...) { return caaadr(car(xs)); }); - define("caadar", [](let const& xs, auto&&...) { return caadar(car(xs)); }); - define("caaddr", [](let const& xs, auto&&...) { return caaddr(car(xs)); }); - define("cadaar", [](let const& xs, auto&&...) { return cadaar(car(xs)); }); - define("cadadr", [](let const& xs, auto&&...) { return cadadr(car(xs)); }); - define("caddar", [](let const& xs, auto&&...) { return caddar(car(xs)); }); - define("cadddr", [](let const& xs, auto&&...) { return cadddr(car(xs)); }); - define("cdaaar", [](let const& xs, auto&&...) { return cdaaar(car(xs)); }); - define("cdaadr", [](let const& xs, auto&&...) { return cdaadr(car(xs)); }); - define("cdadar", [](let const& xs, auto&&...) { return cdadar(car(xs)); }); - define("cdaddr", [](let const& xs, auto&&...) { return cdaddr(car(xs)); }); - define("cddaar", [](let const& xs, auto&&...) { return cddaar(car(xs)); }); - define("cddadr", [](let const& xs, auto&&...) { return cddadr(car(xs)); }); - define("cdddar", [](let const& xs, auto&&...) { return cdddar(car(xs)); }); - define("cddddr", [](let const& xs, auto&&...) { return cddddr(car(xs)); }); + define("caaar", [](let const& xs) { return caaar(car(xs)); }); + define("caadr", [](let const& xs) { return caadr(car(xs)); }); + define("cadar", [](let const& xs) { return cadar(car(xs)); }); + define("caddr", [](let const& xs) { return caddr(car(xs)); }); + define("cdaar", [](let const& xs) { return cdaar(car(xs)); }); + define("cdadr", [](let const& xs) { return cdadr(car(xs)); }); + define("cddar", [](let const& xs) { return cddar(car(xs)); }); + define("cdddr", [](let const& xs) { return cdddr(car(xs)); }); + + define("caaaar", [](let const& xs) { return caaaar(car(xs)); }); + define("caaadr", [](let const& xs) { return caaadr(car(xs)); }); + define("caadar", [](let const& xs) { return caadar(car(xs)); }); + define("caaddr", [](let const& xs) { return caaddr(car(xs)); }); + define("cadaar", [](let const& xs) { return cadaar(car(xs)); }); + define("cadadr", [](let const& xs) { return cadadr(car(xs)); }); + define("caddar", [](let const& xs) { return caddar(car(xs)); }); + define("cadddr", [](let const& xs) { return cadddr(car(xs)); }); + define("cdaaar", [](let const& xs) { return cdaaar(car(xs)); }); + define("cdaadr", [](let const& xs) { return cdaadr(car(xs)); }); + define("cdadar", [](let const& xs) { return cdadar(car(xs)); }); + define("cdaddr", [](let const& xs) { return cdaddr(car(xs)); }); + define("cddaar", [](let const& xs) { return cddaar(car(xs)); }); + define("cddadr", [](let const& xs) { return cddadr(car(xs)); }); + define("cdddar", [](let const& xs) { return cdddar(car(xs)); }); + define("cddddr", [](let const& xs) { return cddddr(car(xs)); }); } template <> @@ -1669,7 +1669,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("eval", [](let const& xs, auto&&...) + define("eval", [](let const& xs) { return cadr(xs).as().mac_env.as().evaluate(car(xs)); // DIRTY HACK! }); @@ -1688,7 +1688,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("finite?", [](let const& xs, auto&&...) + define("finite?", [](let const& xs) { return car(xs).as().is_finite(); }); @@ -1703,7 +1703,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("infinite?", [](let const& xs, auto&&...) + define("infinite?", [](let const& xs) { return car(xs).as().is_infinite(); }); @@ -1718,15 +1718,15 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("nan?", [](let const& xs, auto&&...) + define("nan?", [](let const& xs) { return car(xs).is_also() and car(xs).as().is_nan(); }); - define("exp", [](let const& xs, auto&&...) { return car(xs).as().exp(); }); - define("sqrt", [](let const& xs, auto&&...) { return car(xs).as().sqrt(); }); + define("exp", [](let const& xs) { return car(xs).as().exp(); }); + define("sqrt", [](let const& xs) { return car(xs).as().sqrt(); }); - define("log", [](let const& xs, auto&&...) + define("log", [](let const& xs) { switch (length(xs)) { @@ -1741,19 +1741,19 @@ namespace meevax } }); - define("sin", [](let const& xs, auto&&...) { return car(xs).as().sin(); }); - define("cos", [](let const& xs, auto&&...) { return car(xs).as().cos(); }); - define("tan", [](let const& xs, auto&&...) { return car(xs).as().tan(); }); - define("asin", [](let const& xs, auto&&...) { return car(xs).as().asin(); }); - define("acos", [](let const& xs, auto&&...) { return car(xs).as().acos(); }); - define("sinh", [](let const& xs, auto&&...) { return car(xs).as().sinh(); }); - define("cosh", [](let const& xs, auto&&...) { return car(xs).as().cosh(); }); - define("tanh", [](let const& xs, auto&&...) { return car(xs).as().tanh(); }); - define("asinh", [](let const& xs, auto&&...) { return car(xs).as().asinh(); }); - define("acosh", [](let const& xs, auto&&...) { return car(xs).as().acosh(); }); - define("atanh", [](let const& xs, auto&&...) { return car(xs).as().atanh(); }); + define("sin", [](let const& xs) { return car(xs).as().sin(); }); + define("cos", [](let const& xs) { return car(xs).as().cos(); }); + define("tan", [](let const& xs) { return car(xs).as().tan(); }); + define("asin", [](let const& xs) { return car(xs).as().asin(); }); + define("acos", [](let const& xs) { return car(xs).as().acos(); }); + define("sinh", [](let const& xs) { return car(xs).as().sinh(); }); + define("cosh", [](let const& xs) { return car(xs).as().cosh(); }); + define("tanh", [](let const& xs) { return car(xs).as().tanh(); }); + define("asinh", [](let const& xs) { return car(xs).as().asinh(); }); + define("acosh", [](let const& xs) { return car(xs).as().acosh(); }); + define("atanh", [](let const& xs) { return car(xs).as().atanh(); }); - define("atan", [](let const& xs, auto&&...) + define("atan", [](let const& xs) { switch (length(xs)) { @@ -1795,7 +1795,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("load", [this](let const& xs, auto&&...) + define("load", [this](let const& xs) { return load(car(xs).as()); }); @@ -1818,7 +1818,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("emergency-exit", [](let const& xs, auto&&...) -> object + define("emergency-exit", [](let const& xs) -> object { switch (length(xs)) { @@ -1870,7 +1870,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%read", [this](let const& xs, auto&&...) + define("%read", [this](let const& xs) { try { @@ -1911,7 +1911,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("%write-simple", [this](let const& xs, auto&&...) + define("%write-simple", [this](let const& xs) { write(cadr(xs), car(xs)); return unspecified_object; @@ -1921,12 +1921,12 @@ namespace meevax template <> auto environment::import(decltype("(meevax experimental)"_s)) -> void { - define("make-syntactic-closure", [](let const& xs, auto&&...) + define("make-syntactic-closure", [](let const& xs) { return make(car(xs), cadr(xs), caddr(xs)); }); - define("syntactic-closure?", [](let const& xs, auto&&...) + define("syntactic-closure?", [](let const& xs) { return car(xs).is(); }); @@ -1946,7 +1946,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier?", [](let const& xs, auto&&...) + define("identifier?", [](let const& xs) { return is_identifier(car(xs)); }); @@ -1985,7 +1985,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("free-identifier=?", [](let const& xs, auto&&...) + define("free-identifier=?", [](let const& xs) { auto is_same_free_identifier = [](let const& x, let const& y) { @@ -2045,7 +2045,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - // define("bound-identifier=?", [](let const& xs, auto&&...) + // define("bound-identifier=?", [](let const& xs) // { // return f; // }); @@ -2061,7 +2061,7 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("identifier->symbol", [](let const& xs, auto&&...) + define("identifier->symbol", [](let const& xs) { switch (length(xs)) { @@ -2077,12 +2077,12 @@ namespace meevax } }); - define("transformer?", [](let const& xs, auto&&...) + define("transformer?", [](let const& xs) { return car(xs).is_also(); }); - define("disassemble", [](let const& xs, auto&&...) + define("disassemble", [](let const& xs) { if (0 < length(xs)) { @@ -2100,7 +2100,7 @@ namespace meevax return std::numeric_limits::is_iec559; }); - define("print", [](let const& xs, auto&&...) + define("print", [](let const& xs) { for (let const& x : xs) { @@ -2125,12 +2125,12 @@ namespace meevax * * ---------------------------------------------------------------------- */ - define("foreign-function", [](let const& xs, auto&&...) + define("foreign-function", [](let const& xs) { return make(cadr(xs).as(), car(xs).as()); }); - define("type-of", [](let const& xs, auto&&...) + define("type-of", [](let const& xs) { std::cout << car(xs).type().name() << std::endl; diff --git a/test/vector.cpp b/test/vector.cpp index 1a0d2de67..d8bedd744 100644 --- a/test/vector.cpp +++ b/test/vector.cpp @@ -173,7 +173,7 @@ auto main() -> int { auto module = environment(); - module.define("vector", [](let const& xs, auto&&...) + module.define("vector", [](let const& xs) { return make(for_each_in, xs); });