Arc Forumnew | comments | leaders | submitlogin
Liking "mz" to escape to MzScheme
5 points by CatDancer 5576 days ago | discuss
Some months ago I mentioned that I disliked the choice "$" as the name of a macro to escape to Scheme, my complaint was that such a short symbol was too valuable a name to use on a macro used occasionally, and that more in library code then user code. I had hacked ac.scm so that "(scheme x)" would insert "x" directly in the compiled output, which served a similar purpose to "$" in Anarki but didn't call eval, and so gets compiled at compile time instead of evaluated at run time.

I found that for me, once I started writing more code, "scheme" was too long to easily read the calls I was making to Scheme procedures:

  (let message ((scheme async-channel-get) connection!to-channel)
    ...)
so I changed the keyword to "mz":

  (let message ((mz async-channel-get) connection!to-channel)
    ...)
which, I don't know if you'll see much difference in this little snippet, but I found my brain at least was parsing a lot easier when reading through my program.

If anyone else would like to use this, the hack to arc2/ac.scm is simple:

    (define (ac s env)
      (cond ((string? s) (string-copy s))  ; to avoid immutable strings
            ((literal? s) s)
            ((eqv? s 'nil) (list 'quote 'nil))
            ((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) 'mz) (cadr s))
            ((eq? (xcar s) 'quote) (list 'quote (ac-niltree (cadr s))))