# unix_dict

The file builtins/unix_dict.e (an autoinclude) implements unix_dict() which returns a list of words in a way that is compatible between desktop/Phix and pwa/p2js.
While desktop/Phix reads demo/unixdict.txt, obviously a browser applies all sorts of security and CORS restrictions which effectively prevent the reading of local disk files, and we don’t particularly want to set up a server to honor some GET/POST request, so instead pwa/builtins/unix_dict.js simply contains a machine-generated constant of all 25,107 words, ~284K.
Note that file gets rebuilt when pwa/p2js.exw is run should it not exist or when builtins/unix_dict.e has been modified1, but not when demo/unixdict.txt is modified, and not incorporating any changes made to builtins/unix_dict.e. See pwa/p2js.exw routine rebuild_builtins_and_run_tests() for more details and the equivalent JavaScript code that may need to be kept in line (manually) with desktop/Phix.
1Only because that’s how all the other files are handled, and adding an exclusion just because this one is fairly pointless would be, erm, fairly pointless.

### Example:

Copy

    printf(1,"unix_dict() returns %,d words\n",length(unix_dict()))  -- (currently 25,107)

sequence words = | unix_dict(integer minlen=0, string filename="unixdict.txt") -- Returns a list of English words. The minlen parameter allows optional filtering to those of that length or longer. The filename can be overidden to open other dictionaries placed in the same folder, ie Phix/demo/, but obviously that is desktop-only and is in fact simply ignored in the browser: if you are very lucky maybe one day p2js will issue a transpilation error, but afaik it does not as yet, plus a call may be inside a suitable platform()!=JS or similar guard, and therefore not be an error. If you think a runtime crash in the browser for filename!==undefined would help, that can be arranged.