Factor Language Blog

Module main entry points

Thursday, October 19, 2006

Modules can now define an entry point. Here is the updated contrib/tetris/load.factor:

! Copyright (C) 2006 Alex Chapman
! See http://factorcode.org/license.txt for BSD license.

REQUIRES: contrib/lazy-lists ;

PROVIDE: contrib/tetris {
    "tetris-colours.factor" "tetromino.factor" "tetris-piece.factor"
    "tetris-board.factor" "tetris.factor" "tetris-gl.factor"
    "tetris-gadget.factor"
} {
    "test/tetris-piece.factor" "test/tetris-board.factor" "test/tetris.factor"
} ;

USE: tetris-gadget

MAIN: contrib/tetris tetris-window ;

This means with the latest darcs code (not 0.85) you can now run Tetris simply by starting Factor and entering the following:
"contrib/tetris" run-module
The module is loaded first (unless it has already been loaded).