Hi folks. I made a little hack to the VM that allows you to embed a #!  
string in the front part of a saved Factor image. This way, you can  
build standalone CLI utilities like this:

% ./factor -run=listener
( scratchpad ) USE: hello-world
! save-image* is like save-image, but also takes a commandline to  
embed in the image
( scratchpad ) "hello-world" "-no-user-init -quiet -run=hello-world"  
save-image*
( scratchpad ) ^D
% chmod 755 hello-world
% ./hello-world
Hello world
%

For commandline apps, this could be preferable to the full-blown app  
bundles the deploy tool builds, because the image is a single file can  
be executed, moved around, and installed without having carry a copy  
of the VM and its resources with it. The VM path is coded in the #!  
line, so it can hang out in /usr/local/lib while the image goes in / 
usr/local/bin, ~/bin, or wherever. ocaml uses a similar ploy to make  
bytecode-compiled products executable.

One drawback I can think of is that the VM–image interface is still  
pretty brittle, so if the user rebuilds the VM out from under an  
image, running that image will probably crash and burn unless they  
rebuild it as well. #! also hardcodes the VM path in the image, so the  
VM couldn't be moved without breaking the image's self-executing  
ability. And of course, the #! trick doesn't work in Windows.

-Joe
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to