>>>>> "Simon" == Simon L Peyton Jones <[EMAIL PROTECTED]> writes:
> | Anyway, what it seems to me you lose by doing it the way you described
> | is that you are stuck again if some day you want to set those flags
> | some other way than from the environment variables. For example with
> | pragmas. You can't compile several modules with different settings
> | either, without restarting all of the compiler, it seems to me.
> I regard this as an *advantage*. If I see
...
> The point is, if I *want* to have several behaviours in one run I can always
> use this second technique. But Haskell as it now stands prevents me from
> using the first, even when I *don't* want several behaviours in one run.
> I'd be prepared to pay the pain if I wanted the benefit. Since I don't want
> the "benefit" I don't want the pain.
First, Simon, I think you're a little biased on this issue. I'm sure that
making argv a global constant would be a practical benefit for programs like
GHC, but a compiler is a very specialized application, and exactly the sort
that takes a huge number of arguments and then threads them to all the little
nooks and crannies of a program. Most applications are not nearly so
configurable, and I think there is considerably less burden on the programmer
when it comes to distributing argument values.
Second, I don't think you really addressed Sverker's point. Ideally, a
Haskell program itself is supposed to be as reusable as any of its component
modules, but the way you advocate breaking down the lexical scoping will limit
the reusability of the program as a whole, and might make it less maintainable
in the end.
Suppose, for example, as Sverker suggested that instead of setting the
arguments via the command-line, you set them by reading in a file of argument
settings, one per module. Then you would be stuck with implementing the
argument-passing plumbing anyway.
Third, I could say that choosing to use a functional language is in some
sense also accepting the fact that you are "forced to accept some benefits"
which you could do without. Like overhead associated with closures, or
laziness, or static type systems. But it's not politically correct to make
that point anymore. :)
Fourth, the advantage you claim to get from global flags could also be
gotten from using a reader monad: not only does it hide the plumbing, but it
also explicitly indicates that the value is constant. And last time I looked,
GHC was overflowing with monads, although I don't think they used the class
system so maybe composition/lifting would be a pain.
Last (and least convincing) of all, I might mention that this scheme assumes
a conventional OS like Unix or Windows where program arguments are strict and
not actually lexically scoped. If/when someday somebody invents a declarative
OS, which passes arguments lazily and/or depends on lexical scoping, some
enterprising young programmer might get the bright idea of porting Haskell and
replacing the Unix-cloned I/O system then only to find to his dismay that
every Haskell program written after 1997 including the Glorious Glasgow
Haskell Compiler evaluates its arguments eagerly and doesn't respect lexical
scoping. OK, well, maybe I'm dreaming...
--
Frank Christoph Next Solution Co. Tel: 0424-98-1811
[EMAIL PROTECTED] Fax: 0424-98-1500