Re: [dev] Interesting post about X11

From: Robert Ransom <rransom.8774_AT_gmail.com>
Date: Tue, 22 Jun 2010 03:39:39 -0700

On Tue, 22 Jun 2010 12:22:52 +0200
Mate Nagy <mnagy_AT_port70.net> wrote:

> On Tue, Jun 22, 2010 at 03:10:27AM -0700, Robert Ransom wrote:
> > Scheme *should* be used for everything because at least one good macro
> > system has been designed for it. Lisp macros can do arbitrary
> > computation at compile-time, and the Scheme macro system required by
> > R6RS provides all the power of Lisp macros *and* supports a
> > pattern-matching macro specification syntax for simple syntactic sugar.
> this is exactly the reason scheme macros are horrible and Lisp macros
> are better for your mind and health. This is one of the humongous,
> indefensible warts on the scheme language (the other being #f)

To get rid of #F in IF:

(define-syntax if
  (syntax-rules ()
    ((if test true-exp false-exp)
     (sys:if (eq? test '()) true-exp false-exp))
    ((if test true-exp)
     (sys:if (eq? test '()) true-exp))))

To de-#F predicates:

(define-syntax sys-name
  (lambda (exp)
    (datum->syntax
     exp
     (string->symbol
      (string-append
       "sys:"
       (symbol->string
        (syntax->datum exp)))))))

(define-syntax de-false-semi-predicate
  (syntax-rules ()
    ((de-false-semi-predicate pred-name)
     (define (pred-name . args)
       (sys:or (apply (sys-name pred-name) args) '())))))

(define-syntax de-false-predicate
  (syntax-rules ()
    ((de-false-predicate pred-name)
     (define (pred-name . args)
       (sys:if (apply (sys-name pred-name) args)
               't
               '())))))

Zapping #F elsewhere is another SMOP, much easier than implementing the
sufficiently smart compiler. In any non-Lisp language, this would also
require hacking on the compiler.

Robert Ransom

Received on Tue Jun 22 2010 - 10:39:39 UTC

This archive was generated by hypermail 2.2.0 : Tue Jun 22 2010 - 11:48:02 UTC