Path: utzoo!attcan!uunet!husc6!bbn!rochester!stuart From: stuart@cs.rochester.edu (Stuart Friedberg) Newsgroups: comp.windows.x Subject: Automatic module initialization (was Xtk Resource Converters) Summary: It is NOT hard to do in C Message-ID: <10049@sol.ARPA> Date: 25 May 88 23:54:23 GMT References: <8805252116.AA21083@gilroy.dec.com> Reply-To: stuart@cs.rochester.edu (Stuart Friedberg) Organization: U of Rochester, CS Dept., Rochester, NY Lines: 34 In article <8805252116.AA21083@gilroy.dec.com> haynes@WSL.DEC.COM writes: >This is one of the reasons I hate C. In a reasonable language you would >have module initialization happen automatically at program startup. >Since C doesn't do this, you have to do your own initialization >MANUALLY. > [...] So I'm afraid you're stuck with >either initializing all of your classes manually, and registering the >type converter in the class initialization code, or providing an >explicit intializer for your stuff, and requiring your clients to call it. Nonsense. It is VERY EASY to write a module that does first time initialization in C. It adds maybe 10 lines of code to the module. There is no reason to either (A) require your clients to call an explicit initializer, or (B) initialize any class before a client wants to use it. To wit: static int module_initialized = 0; static void module_initialization() { /* initialize the module */ module_initialized = 1; } /* publically accessible creation routine */ module_create_a_widget() { if (!module_initialized) module_initialization(); /* create a widget or whatever */ } Stu Friedberg {ames,cmcl2,rutgers}!rochester!stuart stuart@cs.rochester.edu