[plt-scheme] Re: Modules, Units, and Classes

From: kanishka (nish2575 at yahoo.com)
Date: Mon May 28 14:28:32 EDT 2007

"You use modules to manage groups of any kind of bindings bindings (for

variables, syntax extensions, functions, METHODS and CLASSES.
You use units mostly for interdependent modules (e.g. for two modules
their signatures=exports+imports depend on each other).
You use classes to implement abstract data types (actually you don't
classes for object-oriented programming in Scheme, they are just

I did a similar survey of options for code organization a little while
back (i did this because i was coming from last actively using c#,
where the first thing you do is decide which namespace to place your
classes in). For the record, some general observations i found:

-although units are powerful and cool, most of the plt scheme code i've
ready hasn't needed that level of parameterization. the popular idiom
amongst planet authors, mzlib's, and collections seems to be use

i tend to be the kind of person that wants the power of a unit around,
but will usually use the simplest tool available. 

-i broke down the various options into: 







..i neglected classes, mixins, and contracts at the time. but i don't
really see classes a tool for large scale program organization, more
for smaller, local organization. just didn't have enough time to
thoroughly read up on contracts. 

from what i read, i differentiated them as follows: 

include- just chunk a large file into multiple files. (one of the only
mechanisms in php (: )

package, namespace - group together runtime names.. i tend to want to
stay away from namespaces. they seem kind of overkill for type of
organizaiton problems i might encounter. 

load - crude, but nice for rapid development initially

module - the default method of organization. most widely supported.
nice for hiding local definitions, without having to use nested defines

collection - when you've really tested your code out, and used it in a
few different circumstances. wnat to reuse it as a library on multiple

unit/sig - when you plan to spend months/years writing lots of
variations/implementations for an interface. or you plan to have
multiple authors writing plugins for an small framework you are writing

on my current project i ended up using load and include. i've been too
busy to learn how to write these library of functions i wrote for
generating sql data access layer code into macros. and since it was
using eval to generate definitions, i couldn't compile it or all the
other code that depended on those definitions. 


____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.

Posted on the users mailing list.