* arguments to expanded let now get proper procedure names so that

(let ((f (lambda (x) x))) f) prints as #<procedure f>.
This commit is contained in:
Abdulaziz Ghuloum 2007-10-10 05:06:31 -04:00
parent ca27d8e626
commit 82eb606715
3 changed files with 28 additions and 6 deletions

Binary file not shown.

View File

@ -156,6 +156,21 @@
(error 'recordize "unbound ~s" x))) (error 'recordize "unbound ~s" x)))
(define (lexical x) (define (lexical x)
(getprop x *cookie*)) (getprop x *cookie*))
(define (get-fmls x args)
(define (matching? fmls args)
(cond
[(null? fmls) (null? args)]
[(pair? fmls) (and (pair? args) (matching? (cdr fmls) (cdr args)))]
[else #t]))
(cond
[(and (pair? x) (eq? (car x) 'case-lambda))
(let f ([cls* (cdr x)])
(cond
[(null? cls*) '()]
[(matching? (caar cls*) args)
(caar cls*)]
[else (f (cdr cls*))]))]
[else '()]))
(define (E x ctxt) (define (E x ctxt)
(cond (cond
[(pair? x) [(pair? x)
@ -221,10 +236,17 @@
(let ([var (cadr x)]) (let ([var (cadr x)])
(make-primref var))] (make-primref var))]
[else [else
;;; should annotate expanded let. (let ([names (get-fmls (car x) (cdr x))])
(make-funcall (make-funcall
(E (car x) #f) (E (car x) #f)
(map (lambda (x) (E x #f)) (cdr x)))])] (let f ([arg* (cdr x)] [names names])
(cond
[(pair? names)
(cons
(E (car arg*) (car names))
(f (cdr arg*) (cdr names)))]
[else
(map (lambda (x) (E x #f)) arg*)]))))])]
[(symbol? x) [(symbol? x)
(or (lexical x) (or (lexical x)
(make-funcall (make-funcall

View File

@ -935,8 +935,8 @@
[find i r ls] [find i r ls]
[fold-left r ls] [fold-left r ls]
[fold-right r ls] [fold-right r ls]
[for-all r ls] [for-all i r ls]
[exists r ls] [exists i r ls]
[member i r ls se] [member i r ls se]
[memp i r ls] [memp i r ls]
[memq i r ls se] [memq i r ls se]