[Hugs-users] Avoiding use of the stack

ajb at spamcop.net ajb at spamcop.net
Sat Nov 20 08:19:06 EST 2004


G'day all.

Quoting Josef Svenningsson <josefs at cs.chalmers.se>:

> In what sense is it wrong, and in what sense does this example show that?

The time that you want to use $! is when you want some argument to some
function to be strict.  Unfortunately, $! and $ have different
associativities to normal function application, requiring you to introduce
readability-imparing parentheses if the strict argument is not the last
one:

        testR2' a n = (testR2' $! (a+n)) (n-1)

If $! and $ were both left-associative, you could write this instead:

        testR2' a n = testR2' $! (a+n) $ (n-1)

Cheers,
Andrew Bromage


More information about the Hugs-Users mailing list