Working with code outside the Factor source tree

I'm trying to start playing with the factor.

So far, I:

  • uploaded an OSX image
  • copied the factor directory to $INSTALL/factor
  • launched the debugger by running $INSTALL/factor/factor

It seems to work fine.

Following the instructions for writing your first factorial program , I noticed that scaffold-vocab generated files in my $INSTALL/factor/work directory. Which I can use for now, but in general, I like to keep a separate $INSTALL directory tree and $CODE directory tree.

So, I am trying to follow the instructions from "Working with code outside the Factor directory tree" to add other directories for the path used to load the code into the factor executable, but I was out of luck.

First I tried to set the environment variable FACTOR_ROOTS :

 % export FACTOR_ROOTS=.:$CODE/Factor:$INSTALL/factor % $INSTALL/factor/factor ( scratchpad ) "work" resource-path . "/usr/local/src/factor/work" ( scratchpad ) ^D 

Then I tried to create a ~/.factor-roots file

 % echo . > ~/.factor-roots % echo $CODE/Factor >> ~/.factor-roots % echo $INSTALL/factor >> ~/.factor-roots % $INSTALL/factor/factor ( scratchpad ) "work" resource-path . "/usr/local/src/factor/work" ( scratchpad ) ^D 

Then I checked if ./.factor-roots needed instead:

 % mv ~/.factor-roots . % $INSTALL/factor/factor ( scratchpad ) "work" resource-path . "/usr/local/src/factor/work" ( scratchpad ) ^D 

Finally, I tried adding it manually:

 % $INSTALL/factor/factor ( scratchpad ) "." add-vocab-root ( scratchpad ) "$CODE/Factor" add-vocab-root ! no, I didn't actually use an environment variable here :) ( scratchpad ) "work" resource-path . "/usr/local/src/factor/work" ( scratchpad ) ^D 

It seems that I missed something fundamental here.

How to write code outside the $INSTALL/factor directory tree and use it as a factor? How can I say scaffold-vocab to build scaffolding in my $CODE/Factor directory?

+4
source share
1 answer

Well, I was able to figure out what I'm doing wrong, thanks to the serious help of slava and erg on #concatenative .

Simply put, resource-path not a way to test the roots of your factor. Like documents, they say that "resolves [s] the path relative to the location of the factor source code."

A more efficient test is simply a vocab-roots get that will retrieve the current list of dictionary roots.

"/path/to/wherever" add-vocab-root will add /path/to/wherever to your dictionary root list and allow you to make "/path/to/wherever" "project" scaffold-vocab so you can create scaffolds in the right place.

As erg said:

I usually make another word, for example
: scaffold-games ( vocab -- ) [ "/home/erg/games" ] dip scaffold-vocab ; "minesweeper" scaffold-games

+4
source

Source: https://habr.com/ru/post/1396639/


All Articles