Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Lisp interpreter

31 views
Skip to first unread message

Ian Darroy

unread,
Dec 31, 2016, 12:47:12 AM12/31/16
to
Hello guys! Happy New Year comming!

I've got a design question about how to construct my application the right way.

I'm writing a small lisp interpreter and it consists of few classes: Reader, Evaluator, Environment, Symbol and Function. My design is bad because hardly all classes depend on each other this way:

Reader needs Symbol to parse input and wrap strings into Symbol's name.
Evaluator fulfills these Symbols with values (each Symbol has all types in it like Number, Function, String and List (I use vector of Symbols)).
Environment keeps map<Name, Symbol> to hold values so Evauator can ask it for them.
Functions devide on builtins and user-defined, all accept vector of Symbols and I've got inheritance for them.

All this is binded with Evaluator, it's like a hypervisor and knows about everything, what makes me sad.

Please, help to make a better design decision. If you know some recourses, I will be thankful!

Alf P. Steinbach

unread,
Dec 31, 2016, 1:04:29 AM12/31/16
to
General advice is to differentiate between interface and implementation
of something.

Two modules can depend on each other's interfaces without depending on
each other's implementations.

This is harder to do with header-only modules, so when you know there's
going to be little mess, separate compilation is probably a good idea.


Cheers!,

- Alf

Ian Darroy

unread,
Dec 31, 2016, 3:09:12 AM12/31/16
to
Thank you

Jorgen Grahn

unread,
Dec 31, 2016, 7:13:26 PM12/31/16
to
On Sat, 2016-12-31, Ian Darroy wrote:
> Hello guys! Happy New Year comming!
>
> I've got a design question about how to construct my application the
> right way.
>
> I'm writing a small lisp interpreter and it consists of few classes:
> Reader, Evaluator, Environment, Symbol and Function. My design is
> bad because hardly all classes depend on each other this way:

I don't know your problem well, but IMO a design doesn't have to be
bad because of interdependencies. Does this design threaten your
actual project?

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
0 new messages