There's no "the compiler". :) There are many compilers. I don't know of any that evaluate those expressions at compile time, but it's certainly not forbidden. Nor would it be exceedingly hard to implement.
<br>But it's not too bad to do it at run time either, because it will (most likely) only be evaluated once at run time.<br><br> -- Lennart<br><br><div class="gmail_quote">On Nov 17, 2007 4:01 PM, Andrew Coppin <<a href="mailto:email@example.com">
firstname.lastname@example.org</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Suppose I write something like this:<br><br> foo :: [Int]
<br> foo = concat (replicate 4 [4,7,2,9])<br><br>The value of "foo" is completely determined at compile-time. So, will<br>the compiler generate calls to concat and replicate, or will it just<br>insert a large list constant here?
<br><br>Obviously, once somebody has completely examined the contents of "foo",<br>after that point it won't matter either way. I'm just curiose.<br>Concatinating some strings is cheap; I sometimes write constructs like
<br>the above using much more expensive operations. (Expensive in time; the<br>space taken up by the result isn't that great.)<br><br>_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">
Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br></blockquote></div><br>