[plt-scheme] verifying whether a symbol is defined at compile time?

From: Eli Barzilay (eli at barzilay.org)
Date: Sun Apr 22 23:14:32 EDT 2007

On Apr 22, Matthew Flatt wrote:
> At Sun, 22 Apr 2007 03:32:36 -0700, "Yin-So Chen" wrote:
> > My motivation for having a conditional define is to make it play
> > nice with the module system, which doesn't work well when having
> > multiple definitions with the same name.  I was hoping there is an
> > "automated" way of detecting whether a symbol is already defined
> > in the current module, if so, either override or not import the
> > definition.
> 
> Within a module, `identifier-binding' should do the trick.

Funny that this came right after the Swindle question -- they're
related.  When you use `defmethod' Swindle is trying to guess whether
you're defining a new method, or adding to an existing one.  See the
code in "collects/swindle/clos.ss" (look for `identifier-binding') for
how it's done -- my guess is that you'll want something similar.

BUT -- having gone through that, I can tell you that you will need a
lot of fighting to get things right.  It's a question whether it's
worth it.  (In other words -- I often think that I should have not
included a `defmethod' -- it's much cleaner to have only `defgeneric'
and `add-method'.)

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.