From: Andrew Cooke
Subject: Overriding functions (Newbie q)
Date: 
Message-ID: <7ueio0$45o$1@nnrp1.deja.com>
Hi,

I have a file of data that describes a tree.  I think it will be easy to
massage the data (using Perl or Python) so that it looks like Lisp data
(a tree), and then I can read it directly.  Each node contains a number
of "properties" (in the data file) that I would like to treat as
functions (ie I will define a function that matches the name of each
node property in the file).

I would like to provide a basic set of functions (that, for example,
print the property name) and then, for particular programs that walk the
tree, replace certain functions with different functions that do
something more interesting.

How do I over-ride functions?  Is it OK to simply declare the basic
definitions (stored in one file) and then re-declare the ones I want to
do something else?  Or is it better to use the package system in some
way (defaults in a package that is used, but not the current package - I
think in this case the Lisp system will ask me which function I want,
which is a nuisance).  Or should I take advantage of CLOS and define the
new functions as "pre" methods?  Or is there another route?

I'm trying to do this in a "Lisp way" - in Java I would parse the tree
and build a data structure, then walk it and call methods appropriately,
rather than using the data itself (in fact, I would probably use
Sablecc, a compiler compiler, to do most of the work for me).  But I
understand that there's no real Lisp equivalent of yacc, and anyway, it
seems simpler to use the data directly....

Cheers,
Andrew


Sent via Deja.com http://www.deja.com/
Before you buy.