Re: [racket-users] Call methods inside a macro

2015-12-08 Thread Alex Knauth
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

Re: [racket-users] Call methods inside a macro

2015-12-08 Thread Guilherme Ferreira
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"))) >

Re: [racket-users] Call methods inside a macro

2015-12-05 Thread Alex Knauth
>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

[racket-users] Call methods inside a macro

2015-12-05 Thread Guilherme Ferreira
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