[racket] Help: Passing a class to a macro and not an identifier

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Wed Sep 15 10:10:04 EDT 2010

I think perhaps my meta-comment was not clear enough.

The basic problem I think you're struggling with Laurent is that
classes are first-class values. On one hand, this means that we cannot
know statically (in general) which methods are available. On the other
hand, we have to know that information if we are to bind them to
variables, since variable binding is a static property.

One course (the define-class suggestion I made earlir) is to restrict
the class system so that classes are not first-class values. When
you've done this, then you can inspect them at compile time and
extract the information you want from them to bind variables.

Another course is not to bind them to variables, but to introduce an
operator that you can use to get the names from your class dynamically
(this may be where Matthias is leading you by suggesting generics).
This means you'll have runtime errors if the method names are not
there, instead of compile time errors (and thus you cannot just
binding them directly to variables, but would instead have to go thru
an operator).

(Technically, one can play tricks to find free variables in some
expression and then try binding them to the method names with a
dynamic check to see if the methods are there, but we're getting a bit
exotic so lets ignore that at least for now.)

Robby


Posted on the users mailing list.