Re: new function or modify read Marc Feeley 17 Dec 2002 15:23 UTC

> I vote for a new function "read-..." and against modifying "read" because there
> might be situations where you need both in one program.

Duplication of names for similar operations is not a good idea.  It is
better to add parameters to the existing read and write function
(either an explicit parameter, probably optional, or a dynamically
scoped "parameter").  The proposed write-showing-shared is a slight
variation on write.  Someone else might (and will) come up with
another slight variation on write, for example writing numbers in a
particular base, or showing normally hidden fields of data structures,
or pretty-printing, etc.  I wouldn't want to have a separate procedure
for each feature.  The problem is that these features should not be
mutually exclusive, you want to be able to turn them on individually.

I much prefer building the functionality into the write (and read)
procedure, and having a parameter object (as in make-parameter of
Chez, PLT, etc) that can turn these features on/off.  For example,
instead of

  (write-showing-shared X)

you would write

  (parameterize ((write-shared #t))   ; write-shared is a parameter object
    (write X))

This way you can combine features as in

  (parameterize ((write-shared #t)
                 (write-radix 16)
                 (write-prettily #t))
    (write X))

Marc