Detecting the Eu version
- Posted by "Juergen Luethje" <j.lue at gmx.de> Dec 13, 2004
- 636 views
Hi all, recently Derek and Pete (L) posted here some useful code, that allows a program to detect the current Eu version at runtime. I think it is especially helpful to use such a functionality in libraries, that require at least a particular Eu version. Concerning Eu 2.5, it can look like this:
include machine.e if routine_id("crash_routine") = -1 then -- crash_routine() was puts(1, "Euphoria 2.5 or later required." -- introduced in v2.5 & "\n\nPress Enter ...") if getc(0) then end if abort(1) end if -- In the following some code is used, that will not run on Eu versions -- prior to 2.5. sequence s s = "Hello World?" s[$] = '!' puts(1, s) if getc(0) then end if
Running the above program on Eu versions prior to 2.5, the program will not crash, but will show the user-defined message, as intended. OK. The issue I'd like to discuss now is, that I think this might not work with future Eu versions. Say in Eu 2.6 there will be a new procedure called new_26_proc(). Then the same approach as above would look something like this:
if routine_id("new_26_proc") = -1 then puts(1, "Euphoria 2.6 or later required." & "\n\nPress Enter ...") if getc(0) then end if abort(1) end if new_26_proc() -- ... or any other code, that will not -- run on Eu versions prior to 2.6.
Using Eu 2.6 or later, the program will work anyway. Using Eu 2.4 or earlier, the program will show the user-defined message, as intended. But using Eu 2.5, the program will crash. ATM I don't see any way how a crash could be prevented in this case. That means when we have say Eu 3.0, version checks at run-time will not work with all versions from 2.5 to 2.9, if the program contains any code that was introduced in a later Eu version. Is this true, or are there logical errors in my considerations? If it's true, I believe even a built-in version() function can't solve the problem, because such a function will act at run-time rather than at compile-time, right? If there is any way to solve this problem, it should be done now in v2.5, so that there will be no "gap" in detecting the Eu version. Regards, Juergen -- Have you read a good program lately?