• simonpj's avatar
    [project @ 2003-06-23 10:35:15 by simonpj] · d28ba8c8
    simonpj authored
    -------------------
    	Dealing with 'main'
    	-------------------
    
    1.  In GHC 6.0, a module with no "module Main ... where" header
        elicited an error "main is not in scope" if 'main' is not defined.  We
        don't want this behaviour in GHCi.  This happened because the parser
        expanded the (absent) header to "module Main( main ) where", and the
        'main' in the export list isn't.
    
    Solution: elaborate HsModule to record whether the 'module ..." header was
    given explicitly by the user or not.
    
    
    2.  Add a -main-is flag, and document it, so that you can have a 'main' function
    that is not Main.main.  Summary of changes
    
    * The -main-is flag nominates what the main function is to be (see the documentation).
    	No -main-is flag 	says that the main function is Main.main
    	-main-is Foo.baz	says that the main function is Foo.baz
    	-main-is Foo		says that the main function is Foo.main
    	-main-is baz		says that the main function is Main.baz
    
      Let's say  you say -main-is Foo.baz
    
    * TcRnDriver injects the extra definition
    	$Mian.main :: IO t
    	$Main.main = baz
      in the module Foo.   Note the naming, which is a bit different than before;
      previously the extra defn was for Main.$main.  The RTS invokes zdMain_main_closure.
    
    * CodeGen injects an extra initialisation block into module Foo, thus
    	stginit_zdMain {
    		stginit_Foo
    	}
      That ensures that the RTS can initialise stginit_zdMain.
    d28ba8c8
ffi-chap.sgml 14.4 KB