Simon L Peyton Jones wrote:
>
> I agree with Sigbjorn about argv, rather strongly, though apparently nobody
> else does.
No, I agree Sigbjorn's proposal is probably a good idea, although I don't
feel strongly either way. (I was just disagreeing with the reasoning that
he used to motivate it.)
> module CmdLineOpts where
>
> argv = unsafePerformIO getArgs
>
> unfoldSize :: Int
> unfoldSize = lookupInt "-funfold-size" argv
>
> useCleverFiniteMap :: Bool
> useCleverFiniteMap = lookup "-fclever" argv
I have a comment, and couple of questions.
First, this will involve scanning argv once for each possible option;
I guess option handling is not likely to be a bottleneck, but still...
this offends some aesthetic sense of mine.
Second, how do you handle syntax errors in the command line arguments?
What does lookupInt do if the integer overflows, or if the argument
is not valid syntax for an integer? Do you check for misspelt or
invalid option names?
> PS. I'm less steamed up about the stdin issue; but I think you missed
> Sigbjorn's point. Yes stdin is a constant now, but he'd like stdin *not* to
> be a constant, so that he could take a value of type IO () that used stdin,
> and reconnect its stdin to (say) a file.
Even if stdin remains a constant, you could still do that, because even
if the handle is a constant, the connection between handle and file can
still vary, just as the file contents can vary.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.