[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new function or modify read
> >>>>> "Marc" == Marc Feeley <feeley@xxxxxxxxxxxxxxxx> writes:
> Marc> (parameterize ((write-shared #t)
> Marc> (write-radix 16)
> Marc> (write-prettily #t))
> Marc> (write X))
> >> >>
> >> >> Except your old code doesn't know anything about the presence of all
> >> >> these flags. In fact, every new feature controlled via these
> >> >> parameters might break the old code.
> Marc> Could you explain why? I explicitly said: "But this will not happen
> Marc> if you code your calls to write in this style: ...", meaning that only
> Marc> "write" is in the scope of the parameterize. There is no old code
> Marc> affected by the parameterize!
> >> Yes, there is, namely if you have this in new code ...
> >> (parameterize ((write-symbols-all-lower-case #t))
> >> (old-code-procedure))
> >> ... and this in old code:
> >> (define (old-code-procedure)
> >> (write (string->symbol "FooBarBaz")))
> >> So PARAMETERIZE has the wrong semantics to enforce what you're
> >> suggesting, and there's too much potential for foot-shooting.
> Marc> Please read what I wrote. Only "write" is in the scope of
> Marc> "parameterize" in new code.
> I did read what you wrote.
Strange... then why did you say "Yes, there is, namely if you have
this in new code ..." which contradicts the premise!
> Marc> Of course you can shoot yourself in the foot if your new code does
> Marc> (parameterize (...) (some-other-function-than-write)).
> Exactly. This is why PARAMETERIZE is the wrong mechanism for this:
> it's a mechanism for dynamic assignment, when what the mechanism we
> really need is lexical in nature.
I guess we disagree on this. I would find it convenient to say at
the beginning of my program something like:
or (parameterize ((write-prettily #t)) (main))
so that all calls to write which **do not** explicitly state if it is
important for pretty-printing to be on or off, will pretty-print their
output. Where it does matter you would state it explicitly:
(parameterize ((write-prettily #t)) (write X))
or (parameterize ((write-prettily #f)) (write X))