This commit is contained in:
Justin Ethier 2020-05-18 19:11:11 -04:00
parent cf6ccc25d9
commit d312b0598c
3 changed files with 5 additions and 4 deletions

View file

@ -1001,10 +1001,9 @@ if (acc) {
(not (assoc 'if renamed))) (not (assoc 'if renamed)))
;; Add a failsafe here in case macro expansion added more ;; Add a failsafe here in case macro expansion added more
;; incomplete if expressions. ;; incomplete if expressions.
;; FUTURE: append the empty (unprinted) value instead of #f
(let ((new-ast (if (if-else? ast) (let ((new-ast (if (if-else? ast)
`(if ,@(map (lambda (a) (convert a renamed)) (cdr ast))) `(if ,@(map (lambda (a) (convert a renamed)) (cdr ast)))
(convert (append ast '(#f)) renamed)))) (convert (append ast (list (void))) renamed))))
(cond (cond
;; Optimization - convert (if (not a) b c) into (if a c b) ;; Optimization - convert (if (not a) b c) into (if a c b)
((and (app? (if->condition new-ast)) ((and (app? (if->condition new-ast))

View file

@ -172,6 +172,7 @@
(or (integer? exp) (or (integer? exp)
(real? exp) (real? exp)
(complex? exp) (complex? exp)
(eq? (void) exp) ;; Poor man's (void?)
(string? exp) (string? exp)
(vector? exp) (vector? exp)
(bytevector? exp) (bytevector? exp)

View file

@ -116,6 +116,7 @@
(define (self-evaluating? exp) (define (self-evaluating? exp)
(cond ((number? exp) #t) (cond ((number? exp) #t)
((boolean? exp) #t) ((boolean? exp) #t)
((eq? (void) exp) #t) ;; Poor man's (void?)
((string? exp) #t) ((string? exp) #t)
((vector? exp) #t) ((vector? exp) #t)
((bytevector? exp) #t) ((bytevector? exp) #t)
@ -159,7 +160,7 @@
(define (if-alternative exp) (define (if-alternative exp)
(if (not (null? (cdddr exp))) ;; TODO: add (not) support (if (not (null? (cdddr exp))) ;; TODO: add (not) support
(cadddr exp) (cadddr exp)
#f)) (void)))
(define (make-if predicate consequent alternative) (define (make-if predicate consequent alternative)
(list 'if predicate consequent alternative)) (list 'if predicate consequent alternative))
@ -1022,7 +1023,7 @@
;; Insert default value for missing else clause ;; Insert default value for missing else clause
;; FUTURE: append the empty (unprinted) value ;; FUTURE: append the empty (unprinted) value
;; instead of #f ;; instead of #f
#f))) (void))))
((define-c? exp) exp) ((define-c? exp) exp)
((define-syntax? exp) ((define-syntax? exp)
;(trace:info `(define-syntax ,exp)) ;(trace:info `(define-syntax ,exp))