[racket] An easy route to define-datatype in BSL?

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Nov 5 09:01:13 EST 2012

I think they are macro bindings that are actually structures with
prop:procedure functions, so that the app macro (like 'special') below, can
check where they came from.

#lang racket

(struct example (f x)
        (λ (e y)
          ((example-f e) (example-x e) y)))

(define a (example + 4))

(a 5)

  (require racket/list)
  (struct macro-example (f x)
          (λ (e y)
            ((macro-example-f e)
             (macro-example-x e)

(define-syntax macro-a
   (λ (now then)
     #`(+ #,now #,@(rest (syntax->list then))))

(macro-a 5)

(define-syntax (special stx)
  (syntax-case stx ()
    [(_ f e)
     (macro-example? (syntax-local-value #'f (λ () #f)))
     #'(f e)]

(special macro-a 5)
(special a 5)

On Mon, Nov 5, 2012 at 6:49 AM, Grant Rettke <grettke at acm.org> wrote:

> On Mon, Nov 5, 2012 at 7:22 AM, Jay McCarthy <jay.mccarthy at gmail.com>wrote:
>> every top-level define (like for 'f') has a special notation on it that
>> says "I'm a function". Since 'a' doesn't have this, then the macro for app
>> in BSL can throw an error.
> What Racket language feature is used to do that?

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121105/83d328b4/attachment.html>

Posted on the users mailing list.