RE: bug/feature/? of ghci with concurrency

2002-10-01 Thread Simon Marlow


> Maybe this is by design, but in case it isn't: I was a little
> suprprised when I came across this behavior of ghci:
> 
>ghci
>...  GHC Interactive, version 5.04.1, for Haskell 98. ...
> 
>Prelude> :m Concurrent
>Prelude Concurrent> let loop c = putChar c >> loop c
>in forkIO (loop 'a') >> (loop 'z')
>
> zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
> zazazazazazaza
>
> zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
> zazazazazazaza
>
> zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
> zazazazazazaza
>Interrupted.
>aPrelude Concurrent> sum [1..100]
>a5050
>aPrelude Concurrent>  1+2
>3

This is really a design choice: there is no inter-thread structure other
than what you program yourself, there are no "process groups", and
pressing ^C sends an exception to the main thread only.  We don't
currently have a way for a Haskell program to get access to *all* the
current threads running, so there's no easy way for GHCi to stop
extraneous threads when ^C is received.

It's really a bug that the other threads are suspended when the prompt
appears (but it might also be called a feature: terminating GHCi after
your example might be difficult otherwise!).

Cheers,
Simon
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



bug/feature/? of ghci with concurrency

2002-10-01 Thread Mark Tullsen

Maybe this is by design, but in case it isn't: I was a little
suprprised when I came across this behavior of ghci:

   ghci
   ...  GHC Interactive, version 5.04.1, for Haskell 98. ...

   Prelude> :m Concurrent
   Prelude Concurrent> let loop c = putChar c >> loop c
   in forkIO (loop 'a') >> (loop 'z')
   zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
   zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
   zazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazazaza
   Interrupted.
   aPrelude Concurrent> sum [1..100]
   a5050
   aPrelude Concurrent>  1+2
   3

Obviously, "loop 'a'" has never been terminated and starts running anytime
execution is in progress.  I might expect that either interrupting the
execution would kill *all* processes or that after interrupting "loop 'z'"
that I would still see the "loop 'a'" executing.

This is on 386 Linux.

- Mark

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs