[racket] "lab notebook on learning process" (was: Re: Macros baffle me)

From: Gustavo Massaccesi (gustavo at oma.org.ar)
Date: Tue May 6 19:23:26 EDT 2014

>> > He wants an Arc-style lambda function. Hmph.

>> Does it mean that I'll get an Arc-style lambda function eventually, or that
>> I'll get an explanation why it's a bad ide— wait, nevermind, I can get
>> whatever I want, 'cause it's Racket. Mwa-ha-ha.

>> (I'd still welcome an explanation, tho.)

>I don't think saving key strokes in Arc-style fashion is good for
>the future reader of my software. But go ahead and re-create the
>syntax or borrow it from the Arc implementation (which is some
>large Racket macro).

In Arc the shorthand for lambdas like [* _ 2] is implemented as a
short readtable extension in MzScheme. It expands [* _ 2] to (fn (_)
(* _ 2)) at read time, and this is interpreted as Arc code. (It’s only
15 lines of code and most of the code is boilerplate.)

Implementation: https://github.com/wting/hackernews/blob/master/brackets.scm

One possible idea put this readtable extension (with a few minor
tweaks) in a language similar to the at-exp language in Racket (
http://docs.racket-lang.org/scribble/reader-internals.html#%28part._at-exp-lang%29
). In this way it’d be possible to use the syntax [* _ 2] in any
language in Racket.

(If this is a good or bad idea, is a mater of taste.)

Gustavo


Posted on the users mailing list.