[plt-scheme] Parameterizing Modules with variables
Others have mentioned parameters. If you only need
compile-time configurability you can use units to
parameterise your code. This has the advantage that
you can instantiate units with different
configurations, but the disadvantage of more syntactic
overhead. For example, MoshiMoshi (a wiki) has a
pipeline of operations that can handle interacting
with the datasource. The datasource is anything that
implements the required signature and could, for
example, be a CVS repository, a database, or just the
filesystem. Later stages in the pipeline could record
a changelog, handle file permissions and so on. By
organising this as units we can plug in different
stages of the pipeline when Moshi is configured
(though we don't have many stages implemented yet).
BTW, its more stylish (to my eye) to parameterise code
with the function it should perform than a flag that
has to be checked. E.g. Emacs has a variable
delete-key-deletes-forward:
If non-nil, the DEL key will erase one character
forwards.
If nil, the DEL key will erase one character
backwards.
I'd replace this variable with the actual function
that should be called (say, delete-forward or
delete-backward). That way your code isn't littered
with conds. You're probably doing this already but I
thought I'd mention it as people who aren't used to
HOFs often program in the style of the Emacs example.
Noel
=====
Email: noelwelsh <at> yahoo <dot> com
Jabber: noelw <at> jabber <dot> org
__________________________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo
http://search.yahoo.com