At 20.34 -0300 0-09-23, Leon Smith wrote:
>I haven't done much digging to figure out what exactly why hugs behaves this
>way, but I've noticed the performance of a windows plunges if there is an
>idle instance of Hugs open. I'm not exactly sure if unix has this same
>problem. I'm far less liable to leave hugs running when I'm using in on
>unix.
[I am not really an expert on this, but I can provide an input, until the
Hugs developing team members have their say.]
You do not say which platform you are using, but my guess is that it is MS
Windows with cooperative multitasking:
Under cooperative multitasking, in order to allow other programs to work,
the program must release time to other programs. In the Hugs source code,
this is done allowBreak(). In addition, the console package or windows
package used to port Hugs must also release time.
Now, when Hugs is in idle mode, it is usually stuck in getc() waiting for
an input. The console package is then stuck in a wait loop. If that loop
does not release enough time to other applications, this will slow down the
whole computer.
So all you have to do is to alter the wait loop in the console package loop
so that it releases more time to other programs. In some compilers, for
example Metrowerks CodeWarrior, this can be done by simply include in the
project a copy of the console source file where the loop is, modify it, and
recompile, because the compiler will let the source file functions override
the library functions. (This is what we did in the Mac port.)
>...Another significant annoyance is
>that one cannot interactively define a functions; one must type it into a
>file and load it into hugs. It really hinders exploration of the language,
>not to mention that it would be really handy when debugging programs. Why
>would this require any significant amount of work to implement in Hugs?
I think this has to with the idea that Haskell is a pure language, so
constructs like x = ... are not viewed as an assignment, but only an
association of x with the expressions. In a console mode, such expressions
would perhaps be viewed as mutative. The actual mutation only takes place,
though, when a new value s associated to a variable name that is already in
use. And mutative variables could be implemented using a state monad.
One could get around this by adding a special interact module to every
module which contains new definitions, but Hugs does not have that.
Hans Aberg