[Project_owners] JavaScript includes ... ?

Daniel Fournier zdev at noos.fr
Sat Mar 19 10:19:20 EST 2005

Alex Vincent wrote:

>On Fri, 18 Mar 2005 22:13:40 +0100, Karsten Düsterloh <mnenhy at tprac.de> wrote:
>>Pete Collins aber hob zu reden an und schrieb:
>>>The problem is extension authors have been bundling pieces of jsLib
>>>and that caused const conflicts in the global namespace causing
>>>script execution to halt.
>>Actually, it's the use of global consts (and vars) that is evil...
>And how many such global variables/constants does JSLib declare??? :)
Mozlib (see my previous post to this thread) solves the constant/global 
plague by using only classes and a specific class member devoted to 
constant properties: this member is named K and it's an object with as 
many properties as the class requires, with a global naming scheme. For 
instance, IO_file_Processor class in io/file package:

this.K =
    INSTANCE_ENABLED:            true,
    INSTANCE_DISABLED:            false,
    PROCESS_BLOCKING:            1,
    START_CONTEXT:                0,
    PID_OBJECT:                    { },        //run method NOT IMPLEMENTED

        //NON FATAL
        NONE:                    0,
        NO_SUCCESS:                1,

        PROCESS_INIT:            -1,
        PROCESS_RUN:            -2,
        PROCESS_KILL:            -3,
        FATAL:                    0xFF        //end of error codes

There's almost no  processing overhead for these constants objects and 
in any class this.K.ERROR.NONE is always 0.

I know that Mozlib is not used by any other projects than mine, but let 
me point out that it has as many (and in many cases more) 
functionalities than JSLib, it's full OO designed using agile 
development style and much more easy to extend (thru subclassing and 
overrding) than JSLib.

Daniel Fournier

More information about the Project_owners mailing list