cs: use #3%$app for #%app

Since `#%app` (used where an applicable structure might show up)
injects its own `procedure?` test and makes sure that that a procedure
is returned to the function position of the application, use `#3%$app`
to make Chez Scheme suppress a redundant `procedure?` check for the
appliction.
This commit is contained in:
Matthew Flatt 2019-09-19 07:25:38 -06:00
parent d02fbebba8
commit 5be9ee424c
7 changed files with 46 additions and 9 deletions

View File

@ -12,7 +12,7 @@
(define collection 'multi)
(define version "7.4.0.9")
(define version "7.4.0.10")
(define deps `("racket-lib"
["racket" #:version ,version]))

View File

@ -12,7 +12,8 @@
"r6rs-readtable.rkt"
"scheme-readtable.rkt"
"parse-makefile.rkt"
"config.rkt")
"config.rkt"
"strip.rkt")
;; Set `SCHEME_SRC` and `MACH` to specify the ChezScheme source
;; directory and the target machine. Set the `MAKE_BOOT_FOR_CROSS`
@ -183,7 +184,7 @@
(lambda (stx)
(syntax-case stx ()
[("noexpand" form)
(orig-eval ($uncprep (syntax-e #'form)))]
(orig-eval (strip-$app (strip-$primitive ($uncprep (syntax-e #'form)))))]
[_
(orig-eval stx)])))
(call-with-expressions
@ -206,9 +207,11 @@
[(eval-when (compile) . rest)
#'(eval-when (compile eval load) . rest)]
[_ stx])))))
(define r (if (struct? ex)
($uncprep ex)
ex))
(define r (strip-$app
(strip-$primitive
(if (struct? ex)
($uncprep ex)
ex))))
(e r))))
(status "Load cmacros using expander")
(load-ss (build-path scheme-dir "s/cmacros.ss"))

View File

@ -52,6 +52,7 @@
$record?
$primitive
$unbound-object?
$app
(rename-out [get-$unbound-object $unbound-object])
meta-cond
constant
@ -598,6 +599,9 @@
[(_ name) name]
[(_ opt name) name]))
(define ($app proc . args)
(apply proc args))
(define tc (make-hasheq))
(define ($tc) tc)
(define ($thread-tc tc) tc)

View File

@ -0,0 +1,30 @@
#lang racket/base
(provide strip-$primitive
strip-$app)
(define (strip-$primitive e)
(cond
[(and (pair? e)
(eq? (car e) 'quote))
e]
[(and (pair? e)
(eq? (car e) '$primitive))
(if (pair? (cddr e))
(caddr e)
(cadr e))]
[(list? e)
(map strip-$primitive e)]
[else e]))
(define (strip-$app e)
(cond
[(and (pair? e)
(eq? (car e) 'quote))
e]
[(and (pair? e)
(eq? (car e) '$app))
(strip-$app (cdr e))]
[(list? e)
(map strip-$app e)]
[else e]))

View File

@ -2,7 +2,7 @@
;; Check to make we're using a build of Chez Scheme
;; that has all the features we need.
(define-values (need-maj need-min need-sub need-dev)
(values 9 5 3 1))
(values 9 5 3 2))
(unless (guard (x [else #f]) (eval 'scheme-fork-version-number))
(error 'compile-file

View File

@ -58,7 +58,7 @@
(syntax-case stx ()
[(_ rator rand ...)
(with-syntax ([n-args (length #'(rand ...))])
#'((extract-procedure rator n-args) rand ...))]))
#'(#3%$app (extract-procedure rator n-args) rand ...))]))
(define |#%call-with-values|
(|#%name|

View File

@ -16,7 +16,7 @@
#define MZSCHEME_VERSION_X 7
#define MZSCHEME_VERSION_Y 4
#define MZSCHEME_VERSION_Z 0
#define MZSCHEME_VERSION_W 9
#define MZSCHEME_VERSION_W 10
/* A level of indirection makes `#` work as needed: */
#define AS_a_STR_HELPER(x) #x