forked from alex-eg/sex
parenthesise a conditional without a helper to do it for
This commit is contained in:
@@ -909,10 +909,9 @@
|
|||||||
;; It groups to the right, so its else arm is written at
|
;; It groups to the right, so its else arm is written at
|
||||||
;; `conditional-else', just looser: a chain there stays bare,
|
;; `conditional-else', just looser: a chain there stays bare,
|
||||||
;; `a ? x : b ? y : z', and an assignment does not.
|
;; `a ? x : b ? y : z', and an assignment does not.
|
||||||
(define (c-if/expr . args)
|
(define (c-if/expr c p . rest)
|
||||||
(c-maybe-paren '? (apply c-if/expr/aux args)))
|
(c-maybe-paren
|
||||||
|
'?
|
||||||
(define (c-if/expr/aux c p . rest)
|
|
||||||
(let lp ((c c) (p p) (ls rest))
|
(let lp ((c c) (p p) (ls rest))
|
||||||
(cond
|
(cond
|
||||||
((or (eq? c 'else) (eq? c #t))
|
((or (eq? c 'else) (eq? c #t))
|
||||||
@@ -926,7 +925,7 @@
|
|||||||
(lp (car ls) (cadr ls) (cddr ls))
|
(lp (car ls) (cadr ls) (cddr ls))
|
||||||
(lp 'else (car ls) '())))))
|
(lp 'else (car ls) '())))))
|
||||||
(else
|
(else
|
||||||
(c-or (c-in-test (c-expr c)) (c-expr p))))))
|
(c-or (c-in-test (c-expr c)) (c-expr p)))))))
|
||||||
|
|
||||||
(define (c-if . args)
|
(define (c-if . args)
|
||||||
(fmt-if fmt-expression?
|
(fmt-if fmt-expression?
|
||||||
|
|||||||
Reference in New Issue
Block a user