
On Sat, Nov 17, 2007 at 04:10:58PM +0000, Andrew Coppin wrote:
Stefan O'Rear wrote:
On Sat, Nov 17, 2007 at 04:01:34PM +0000, Andrew Coppin wrote:
Suppose I write something like this:
foo :: [Int] foo = concat (replicate 4 [4,7,2,9])
The value of "foo" is completely determined at compile-time. So, will the compiler generate calls to concat and replicate, or will it just insert a large list constant here?
The compiler will generate calls to concat and replicate.
OK. I presume this is due to the fact that the result of executing an expression at compile-time could be arbitrarily large?
Yes, and it's not even guaranteed to terminate.
Are there any buttons that can be twiddled to control this behaviour?
Not that I'm aware of, though you can hack something with RULEs probably.
For that matter, when I say "[4,7,2,9]", what does that compile into? Some data structures in memory? Or code to actually build said structures?
Both. A curious feature of the STG machine is that constructor thunks and evaluated data are represented identically in memory. Stefan