Re: load user defined module
- Posted by Robert Craig <rds at RapidEuphoria.com> Nov 07, 2002
- 424 views
Derek Parnell writes: > Rob, how would you recommend that coders deal with > this issue of platform-specific code, using the > current incarnation of Euphoria? You can use platform() to determine which platform you are running on. platform() is fast. It's as if you had coded a constant, like 1, 2 or 3. No subroutine call is made. Euphoria does not have conditional compilation built into it, like C does. I'd like to keep it that way. Why add a new concept to the language, for such a small advantage? With conditional compilation, or a preprocessor of some kind, you could eliminate code that's only used on another platform, thereby saving a few K bytes. However it's extremely rare, and getting rarer each year, for a program to run out of memory because it contains too much code. It's almost always an excess amount of data that causes the problem. Over time, programs grow linearly (at most) in size, while memory is still growing exponentially, so I expect this to be even less of a problem in the future. If you really want to save a few K by stripping out code, you can develop your own simple preprocessor in an hour or so. I know from coding in C, that it's more readable if all your nested conditional statements are at the same linguistic level, using if-else, rather than having two levels, with static ifdef's and dynamic if's mixed together. Something I could do is optimize statements like: if platform()=LINUX then code-block-1 else code-block-2 end if so that no intermediate code is generated for code-block-2 when the platform is LINUX. I'd rather do that, than introduce conditional compilation. Also the code above, when translated with E to C, will produce C code like: if 3 = 3 then code-block-1 else code-block-2 end if where I know that Watcom (at least) will eliminate code-block-2 at compile-time. Keep in mind also, that the 2-pass binder and the translator will eliminate all unused routines. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com