The latest version of this hack is scheme0


Arc compiler hacks

Superseded by scheme0.



diff --git a/ac.scm b/ac.scm
index 791a4ca..3f1663b 100644
--- a/ac.scm
+++ b/ac.scm
@@ -22,6 +22,7 @@
         ((ssyntax? s) (ac (expand-ssyntax s) env))
         ((symbol? s) (ac-var-ref s env))
         ((ssyntax? (xcar s)) (ac (cons (expand-ssyntax (car s)) (cdr s)) env))
+        ((eq? (xcar s) 'ac-scheme) (cadr s))
         ((eq? (xcar s) 'quote) (list 'quote (ac-niltree (cadr s))))
         ((eq? (xcar s) 'quasiquote) (ac-qq (cadr s) env))
         ((eq? (xcar s) 'if) (ac-if (cdr s) env))


(= ac-denil       (ac-scheme ac-denil))
(= ac-global-name (ac-scheme ac-global-name))
(= ac-niltree     (ac-scheme ac-niltree))

; for when we can't use assign

(mac ac-set-global (name val)
  (w/uniq (gname v)
    `(with (,gname (ac-global-name ,name)
            ,v ,val)
       (ac-scheme (namespace-set-variable-value! ,gname ,v))

(= scheme-f (read "#f"))
(= scheme-t (read "#t"))

(ac-scheme ...)

The ac-scheme syntax quotes an expression, protecting it from being compiled by the Arc compiler. The expression is passed through unchanged to the MzScheme language that Arc is written in, and thus is interpreted as an MzScheme expression by MzScheme.

 arc> (ac-scheme (let ((a 3))
                   (+ a 20)))

What works and doesn’t work inside an ac-scheme expression is highly dependent on the precise details of how Arc code is compiled into Scheme code. For example, the arc3 compiler happens to compile an Arc lexical scope into an MzScheme lexical scope, and keeps the same variable names:

 arc> (let a 4
        (ac-scheme (* 2 a)))

but this could completely change in another release of Arc.

An Arc macro can expand into an ac-scheme form, and so can generate the Scheme code which is tunneled through the Arc compiler.

(ac-global-name name)

ac-global-name takes an Arc global variable name, and returns the name of the global variable inside of MzScheme.

(ac-denil lst)

Converts an Arc list into an MzScheme list by converting the trailing nil into an MzScheme '().

(ac-niltree lst)

The reverse of ac-denil: converts an MzScheme list into an Arc list by changing MzScheme '() into Arc’s nil.

(ac-set-global name value)

Sets the Arc global variable name to value. Useful when we need to bypass assign.

scheme-t, scheme-f

The Scheme true and false values, #t and #f.

See also

scheme0, the latest version of this hack.

Get this hack

Download ac0.patch and ac1.arc, or use the hackinator:

$ hack \ \ \


This patch is in the public domain. The combination of this patch and Arc may be redistributed or modified under the same terms as Arc itself.

Contact me

Twitter: awwx
Email: andrew.wilcox [at]