From a5c1d01653cb0b93f152513cd01029e42a43eeb6 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Mon, 13 Apr 2015 13:51:21 -0400 Subject: [PATCH] Precompute application of a primitive to literals Precompute primitives when it is safe to do so --- trans.scm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/trans.scm b/trans.scm index 2b58b17d..7d091244 100644 --- a/trans.scm +++ b/trans.scm @@ -772,6 +772,9 @@ cell set-car! set-cdr! + string->symbol ;; Could be mistaken for an identifier + string->list ;; Mistaken for function call (maybe OK if it was quoted, though). same for above? + ;; I/O must be done at runtime for side effects: current-input-port open-input-file close-input-port @@ -1433,12 +1436,9 @@ (cons (car ast) (map (lambda (a) (convert a renamed)) (cdr ast))))) - ;; TODO: want to enable this, but requires adding stuff to the - ;; runtime, such as floating point numbers - ;; - ;(if (precompute-prim-app? converted) - ; (eval converted) ;; Evaluate now, if possible - converted));) + (if (precompute-prim-app? converted) + (eval converted) ;; OK, evaluate at compile time + converted))) ((lambda? ast) (let* ((args (lambda-formals->list ast)) (ltype (lambda-formals-type ast))