[racket] Redex question: parameterizing a language definition

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Thu Apr 4 19:00:18 EDT 2013

On Apr 4, 2013, at 6:32 PM, Lindsey Kuper wrote:

> On Thu, Apr 4, 2013 at 11:15 AM, Matthias Felleisen
> <matthias at ccs.neu.edu> wrote:
>> Lindsey, in your case, I believe the 'rabbit hole' can be avoided.
>> From what I understand each family in lambdaLVar is (almost) uniformly
>> generated from a grammar 'functor' that receives a lattice (let's say
>> one for now), computes some grammatical clauses -- and may add some
>> primitive operations for working on the lattice, which is trivial --
>> and returns that grammar.
> Yes, that sounds very much like what I want to do.

I have done something like this, though for toy languages, but it should work for a real language. 

> Will this sort of thing be possible in a future-Redex-with-modules?

I expect so, but the module system will not be functiorial. 

>> The reduction relation itself does not depend on the generated grammar
>> other than the notion of value you need for beta-v.
>> So, I think that you could use _Racket_'s syntax system to compute
>> the grammar. This is quite different from extending a base grammar
>> with new features or value clauses but as I said at the beginning,
>> it is closer to the way you describe lambdaLVar.
> So, in other words, have a macro that generates a Redex grammar?  I
> can give that a try.  I did think that might be what I would end up
> doing, but wanted to see first if I could get the results I wanted
> without leaving Redex (and extending a base grammar was a kind of
> hacky attempt to stay within Redex).

The point of an embedded DSL is that the designer admits that not all use cases are anticipated and therefore provides an escape hatch for general computations. In the Redex-Racket case, we have the advantage that you can escape from Reded to Racket and that you can enter back into Redex from Racket. 

It really works. -- Matthias

Posted on the users mailing list.