• load() search paths...

    From Digital Man@VERT to Deuce on Thursday, August 06, 2009 16:01:04
    Re: load() search paths...
    By: Deuce to All on Wed Aug 05 2009 04:22 pm

    So, after looking at the vast (and increasing) number of *.js files in the exec directory which are not intended to be executed but are instead intended to be load()ed by some other script, I've started thinking about a library system for the JS load() method. My initial thoughts are something like the following:

    - There be some array of search paths for load() which can be added to by a
    script. Additions can be at either end of the array, and these paths can be
    either absolute or relative.
    - If the path is absolute, only a single directory will be searched.
    - If the path is relative, two directories will be searched, a "mods"
    style directory and a stock directory. The question of if these belong
    under a shared parent directory (ie: jslibs) or under the exec/mods
    directory is an open question.
    - Some way of specifying an initial list (in the ini file)

    You would end up then with something like this:
    jslibs/
    std/
    sbbs/
    ars_defs.js
    nodedefs.js
    sbbsdefs.js
    sockdefs.js
    uifcdefs.js
    irc/
    irc-default.js
    irclib.js
    ircd/
    ircd_channel.js
    ircd_server.js
    ircd_unreg.js
    ircd_user.js
    mods/
    irc/
    irc-cyan.js
    Etc.

    This change would impact all JS files, but with reasonable defaults, the impact could be mitigated.

    Comments?

    I like the idea of the dynamic search-path appendage ability, allowing 3rd party scripts (e.g. games, add-ons) to (easily) store all their files in some directory other than 'exec'.

    I think the default directory for most scripts should still be mods & exec. What do you think of:

    exec/
    login.js
    logon.js
    listserver.js
    nntpservice.js
    etc.
    exec/include
    *defs.js
    *lib.js
    *util.js

    where 'exec' can be replaced with 'mods' (and is searched first), as is the current scheme.

    You could use 'libs' instead of 'include' (the name isn't that important), but I would just add one new default directory and move the lib/include type files there. I wouldn't really call it a 'library system', as libraries historically, are collections (e.g. archives) of modules with callable functions. That's not exactly describing the contents of the *defs.js, *util.js, and *lib.js files we have.

    digital man

    Snapple "Real Fact" #83:
    Googol is a number (1 followed by 100 zeros).

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ telnet://vert.synchro.net