TH - splicing with functions defined in the same source file

Ian Lynagh igloo at earth.li
Mon Dec 4 07:24:57 EST 2006


On Thu, Nov 30, 2006 at 02:12:48AM +0000, Simon Peyton-Jones wrote:
> 
> 2.  You have to compile all the code before your cut-point to byte-code, just in case it's invoked by a splice afterwards.  This is in addition to compiling it to machine code (assuming that's what the main compilation does).
> 
> Concerning (2), the thought of compiling all of every module to bytecode, on the off chance that a later splice might need it, seems unattractive to me (although it might work fine).  To predict, instead, which definitions will be needed means looking at the free variables of later splices, and taking a kind of transitive closure.  Possible but sounds like real work.  This is probably the main reason I've never attempted it.

I don't know if the code is currently structured in a way that would
make this easy, but in principle laziness could take care of only
byte-code compiling bits we need couldn't it? It would probably need an
unsafeInterleaveIO for loading the compiled objects of imports used, but
it doesn't seem like it should be impossible.

Also, we'd only need to do the bytecode compilation when -fth is on, so
it shouldn't be a performance hit for normal usage even if we did the
bytecode compilation whether the splices need it or not.


Thanks
Ian



More information about the Glasgow-haskell-users mailing list