The Awesome Factor

Using .factor-boot-rc and .factor-rc

Wednesday, November 15, 2006

Update: I changed the syntax to work with the new directory layout.

The two resource files Factor tries to run, if they exist, are .factor-boot-rc and .factor-rc, at bootstrap and run-time respectively. You have to create these files yourself and place them in your home directory, e.g. the directory returned by the home word.

If I used Textmate on a Mac, my .factor-boot-rc would look like this:

USING: modules namespaces ;
REQUIRES: libs/textmate ;

Here is the boot file for gvim in Windows XP:

USING: modules namespaces ;
REQUIRES: libs/vim ;
USE: vim
"c:\\program files\\vim\\vim70\\gvim.exe" vim-path set-global

Now for loading libraries. Some of the modules in contrib/ require that you load your library before running. Here are three examples of a .factor-rc that loads libraries.

Loading PostgreSQL on a Mac:

USING: alien ;
"postgresql" "/opt/local/lib/postgresql81/libpq.dylib" "cdecl" add-library

PostgreSQL and SQLite on Windows:

USING: alien ;
"postgresql" "C:\\Program Files\\PostgreSQL\\8.1\\bin\\libpq.dll"
    "cdecl" add-library
"sqlite" "C:\\Program Files\\sqlite\\sqlite3.dll"
    "cdecl" add-library

SQLite on Linux:

USING: alien ;
"sqlite" "libsqlite3.so" "cdecl" add-library