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

From: Jos Koot (jos.koot at telefonica.net)
Date: Mon May 28 15:25:23 EDT 2007

Hi,
Recently I became concious of the fact that I am using modules where others may prefer object classes. I like the module system 
because making a module is it is much more simple than making an object class (mho). To understand why, simply compare the amount of 
documentation of modules with that of object classes. Modules are very well separated from the users environmement and allow you to 
provide variables without being afraid that they could be corrupted by the user. They also provide an excellent tool for maintaining 
a well defined internal state as well as for the redefinition of syntaxes without confusion between the original ones and the 
redefined ones. Furthermore, modules can as easily be extended like classes (again mho) I use fresh namespaces primarly for testing 
purposes, in particular for the simulation of sesssions in the interactions window.
Btw, making a good testing tool is not simple if you want to include tests on generated standard output and exceptions. You have to 
make sure that written/displayed/printed output will be done in a predetermined and well defined way and that error messages will 
always look the same. For example, the error messages produced by a compiled module may differ from those of a module that has not 
(yet) been compiled. This is NOT a criticism on PLT Scheme, on the contrary, for the only systems that can never surprise you/me 
are necessarily trivial.
Kind regards, Jos Koot

----- Original Message ----- 
From: "kanishka" <nish2575 at yahoo.com>
To: <plt-scheme at list.cs.brown.edu>
Sent: Monday, May 28, 2007 8:28 PM
Subject: [plt-scheme] Re: Modules, Units, and Classes


>>>
> "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
> need
> classes for object-oriented programming in Scheme, they are just
> syntactic
> sugar)."
>>>
>
> 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
> modules.
>
> 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:
>
> include
>
> load
>
> modules/collections
>
> namespaces
>
> packages
>
> units/sigs
>
> ..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
> projects
>
> 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.
>
> kanishka
>
>
>
> ____________________________________________________________________________________Boardwalk for $500? In 2007? Ha! Play Monopoly 
> Here and Now (it's updated for today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 



Posted on the users mailing list.