[racket] Best Way to Really Understand the Compilation and Execution Model?

From: Nick Sivo (nicksivo at gmail.com)
Date: Mon Aug 5 13:06:36 EDT 2013

I'm aware of defmacro and even understand its implementation (cute
trick!), but I need to eventually get something like this to work:

(require compatibility/defmacro)

(define (my-cdr lst)
  (cdr lst))

(defmacro drop-first-form args
  `(begin ,@(my-cdr args)))

(drop-first-form
 (displayln 1)
 (displayln 2))

Where the above just works and displays 2.

I'll check out the latest research papers too.

Thanks,
Nick

On Mon, Aug 5, 2013 at 1:40 AM, Noel Welsh <noelwelsh at gmail.com> wrote:
> Does defmacro do what you want?
>
> http://docs.racket-lang.org/compatibility/defmacro.html?q=defmacro#%28form._%28%28lib._compatibility%2Fdefmacro..rkt%29._defmacro%29%29
>
> In terms of grokking the macro system you probably want to read some of the
> research papers, which you can find from links here:
>
> http://racket-lang.org/people.html
>
> Racket's macro system is really cutting edge, so it doesn't have a large
> body of text explaining it.
>
> HTH,
> N.
>
>
>
> On Sun, Aug 4, 2013 at 9:50 PM, Nick Sivo <nicksivo at gmail.com> wrote:
>>
>> Hello everyone,
>>
>> I work on Hacker News[1], which is written in Arc[2], and am tasked
>> with making it faster.  The Arc compiler targets Racket[3], but
>> doesn't do so in such a way that function names or source locations
>> are preserved.  This makes output from the sampling profiler and error
>> messages mostly useless.
>>
>> I'd like to make Arc work as a Racket language (and in the process
>> preserve srclocs and names), and have made some progress[4].  However,
>> I'm hitting a wall trying to implement Arc's macros.  Specifically, I
>> need to find a way for the macros themselves to use previously defined
>> Arc functions as part of their processing. I understand that there are
>> good reasons for Racket's hygiene and syntax phases, but I'm
>> implementing an existing language that has its own strong opinions.
>> I'm almost certain that accomplishing my goal is possible with the
>> right understanding, but despite reading much of the Racket Reference,
>> I don't truly get it yet.
>>
>> With that motivation in mind, what's the best way for me to become
>> intimately familiar with Racket's runtime, execution and compilation
>> model? Should I read through and make sure I understand the debugger?
>> The macro stepper?  Is there any kind of guide to Racket Internals?
>>
>> Thanks for any advice.
>>
>> Best,
>> Nick
>>
>> [1] https://news.ycombinator.com
>> [2] http://arclanguage.org
>> [3] Well, really mzscheme
>> [4] https://github.com/kogir/rark
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>
>

Posted on the users mailing list.