If you have an object at compile time, then you have it at compile time and not
at runtime. If you have an object at runtime, you don't have it at compile
time. Your example fails because it tries to use a compile time object at
runtime.
The `for-syntax`, `define-for-syntax`, and `begin-for-syn
Thank you Alex for your help. Considering the second example,
in the reply, what if I need to return the object itself, for example:
> #lang racket
> (require (for-syntax racket/class))
> (define-for-syntax foo-class%
> (class object%
> (super-new)
> (define/public (get-foo) "foo")))
>
>From your example I suspect that you want a macro that expands to a method
>call:
#lang racket
(define foo-class%
(class object%
(super-new)
(define/public (get-foo) "foo")))
(define-syntax (say-hello stx)
(syntax-case stx ()
[(_ foo)
#'(display (string-append "Hello " (send foo g
Hello everyone,
Consider this example:
(define foo-class%
(class object%
(define/public (get-foo) "foo")))
(define-syntax (say-hello stx)
(syntax-case stx ()
[(_ foo)
(with-syntax ((foo-name (send #'foo get-foo)))
#'(display (string-append "Hello " foo-name)))]))
When t
4 matches
Mail list logo