Re: My Lobbying
- Posted by Derek Parnell <dparnell at BIGPOND.NET.AU> Sep 07, 2000
- 512 views
----- Original Message ----- From: "irv" <irv at ELLIJAY.COM> To: <EUPHORIA at LISTSERV.MUOHIO.EDU> Sent: Thursday, September 07, 2000 1:35 AM Subject: Re: My Lobbying > > if defined, if not defined: > > One obvious use here is when declaring constants: > > you have a program written declaring constants and some constants > > generate errors because they are already declared in someone elses > > program (like Win32Lib).... > > Yes, proper handling of namespacing is a far better solution to this > problem than "if defined" could ever be. See just about any C program > for proof of the awkwardness of that approach. > > Besides, I see no way that "if defined" could help in the situation you > propose: > > if defined x then -- oh,oh, x was already used in Win32lib > constant myx = 3 > elsif defined myx then -- oops, myx declared in Jiri's fonts > constant anotherx = 3 > elsif defined anotherx then -- oops, declared in Freds Functions > constant yetanotherx = 3 > .... > After all this, how does your program know to refer to yetanotherx > in place of the original x? > Do you have to change all the following code? I was thinking more along the lines of ... if not defined True then constant True = 1 end if if not defined False then constant False = 0 end if if not defined trim then function trim(sequence s) . . . end function end if etc... As many commonly required names (constants and functions) are missing from standard Euphoria, people have a tendency to re-invent them in the various generic include files. But not always. The namespace resolution should be one way of overcoming this, however it could still mean that unnecessary items get defined. Unnecessary, because a perfectly good definition might already exist, but because I can't be sure I define it again anyway, then use my definition and ignore the earlier one. --- cheers Derek