Quick hack to support heterogeneous let forms.

This commit is contained in:
Georges Dupéron 2016-09-11 13:55:45 +02:00
parent a8c4fd4fcf
commit 6103097fe5
3 changed files with 55 additions and 21 deletions

View File

@ -4,6 +4,7 @@
trivial/format
trivial/function
trivial/math
trivial/list
trivial/regexp
trivial/vector)
@ -51,4 +52,15 @@
(define/public (yolo)
(new f%))))
(check-false (not (new f%))))
)
;; let*
(let*: ([v (list 1 2 3)]
[w v]
[k 42])
(ann (length: w) 3))
;; let with different kinds of bindings
(let: ([v (list 1 2 3)]
[k 42])
(ann (length: v) 3)))

View File

@ -1,7 +1,9 @@
#lang typed/racket/base
(provide
define: let:
define:
(rename-out [let:: let:])
let*:
(all-from-out trivial/private/set-bang)
)
@ -47,3 +49,23 @@
(lst-let stx)
(rx-let stx)
(vec-let stx)))))
(define-syntax (let*: stx)
(syntax-case stx ()
[(_ ([v b]) . body)
#'(let: ([v b])
. body)]
[(_ ([v b] [vv bb] ...) . body)
#'(let: ([v b])
(let*: ([vv bb] ...)
. body))]))
(define-syntax (let:: stx)
(syntax-case stx ()
[(_ ([v b]) . body)
#'(let: ([v b])
. body)]
[(_ ([v b] [vv bb] ...) . body)
#'(let: ([tmp b])
(let*: ([vv bb] ...)
(let: ([v tmp]) . body)))]))

View File

@ -1,4 +1,4 @@
#lang typed/racket/base
(provide (rename-out [define: define] [let: let]))
(provide (rename-out [define: define] [let: let] [let*: let*]))
(require trivial/define)