What does unsafePerformIO do to the stack

Bernd Brassel bbr at informatik.uni-kiel.de
Thu Feb 7 08:29:47 EST 2008


Simon Marlow wrote:

> So the upshot is: you can use unsafeDupablePerformIO right now, or you
> can wait until I've tested and committed this patch to get
> tail-recursion with unsafePerformIO.

Wow, thank you for the detailed answer! That was really interesting.

> I've no idea how it works in Hugs, you'll have to ask them :)

At least I can tell you how it is done in that other interpreter I
mentioned. The reason that you can be better for that example is that
the argument of badStack is not shared. No need to push an update frame
for it. I am pretty sure that it is the same with the other compiler,
both for Curry not for Haskell btw., but like you I am not sure with Hugs.

If the ghc does not take into account what is statically not shared, I
guess there is potential for a good optimization here which would go
well beyond unsafe programs.

Greetings and thanks!
Bernd


More information about the Glasgow-haskell-users mailing list