# Byte counting policy for library imports in Factor

As this month's LotM (Forth) was not gaining much participation, I guessed it's partly because it's way too low-level, so I was looking into Factor as a modern, high-level alternative to Forth. If it goes well, I'm planning to add a LotM proposal so that other people can look into it.

But I found a major issue in code golf scoring for Factor: most submissions omit the required imports from the byte count. Some of them actually work when tested in the REPL without any setting, but many don't (as the REPL loads only part of the libraries by default). (The existing answers in Factor can be found via this SEDE query.)

They can be made to work if we add a global setting script in .factor-rc like this:

! .factor-rc
USE: parser auto-use

! script.factor
1.2 dup + floor .


Try it online!

Inside script.factor, we need to load kernel library for dup, math for +, math.functions for floor, and prettyprint for .. Without the .factor-rc file, we'd need to write this to make it work:

USING: kernel math math.functions prettyprint ;
1.2 dup + floor .


(Note that using the rc-file generates a warning to STDOUT, so it can't be used for a full program.)

Otherwise, if we assume REPL environment, "auto use" is a built-in feature, which (disabled by default) can be enabled via mouse or by typing auto-use<ENTER>. (parser library is available by default in the REPL.) REPL also starts with "auto use" enabled by default if the same .factor-rc exists.

So the question is: Should I count the content of .factor-rc file (20B), or auto-use<ENTER> command in REPL (9B), if I want to use this feature and exclude imports from byte count?

FWIW, an earlier mention of "auto use" can be found in this answer.

• nice to see someone continuing my legacy as Factor proselytizer while i'm inactive here :)
– cat
Dec 6, 2020 at 0:08

• The existence of the specific .factor-rc file can be seen as a system-wide setting like APL's index origin. Also, having auto-use enabled on a system is reasonable, since the feature itself was designed to "help during development", and the intended use case is to turn it on and load a source file.
• But, it is an answerer's responsibility to check that the answer actually works with auto-use. It has a couple of restrictions: it cannot load words from a library that is considered too obscure (e.g. xxx.private libs), and it cannot load if the word is found in multiple libraries.
• If you don't have Factor installed on your machine, you can still check by entering your submission in the code section on this TIO. (Make sure the entire code has no stack effect, i.e. ( -- ).) If it runs without error, your submission is valid.