- Posted by CoJaBo <cojabo at suscom.net> Feb 14, 2004
- 1761 views
Eu 2.5 suggestions(very useful) Some of the following is missing from Euphoria and would be very helpful to me and many other programmers. I would like to see this in Eu 2.5. Please take these into consideration. "eval()" commands: I would really like to see a way to do an "eval()" type command. Many other languages have something like this. Since "dynamic includeing" won't work in eu 2.5 or bounnd programs, this is a very important feature. eval(sequence eval_commands,integer global_type,integer crash) eval_commands is a sequence of commands global_type is: 0-No routines/varibles (even global) exist in main program 1-Only routines/varibles declared as global exist in main program 2-All routines/varibles exist in main program This would help in some programs. if crash is true, if it encounters an error (like 1/0) than the program dies with (or a crash routine, see below) ex.err, otherwise, it returns an error code like below Example: integer a,global_type sequence eval_commands eval_commands=" include incl_file.e--should allow including(This could be used \n --instead of complex "dynamic includeing" libraries), \n --and shouldn't insert the include file here when binding \n if a then \n ?a \n end if \n" --It would also be helpful to be able to split strings across multiple lines. --new lines would be ignored, so still use '\n'. --So: --"line 1\n --line 2" --would be the same as --"line 1\nline 2" a=7 global_type=1 ?eval(eval_commands,global_type,0) Displays: 7(value of a) 0(eval encountered no errors or an error code) ____________________________________________________________ Crash callback A way to setup a callback function would allow programs to save user data before exiting with ex.err. Programs like Win32Lib IDE, and webservers almost require this. set_crash(integer routine_id) routine_id is the routine id of the function it calls the function with an error code(like 5 for divide by 0), a sequence with info about the error(like a line #, invalid subscript, ect.) and a text string with the complete text error message( "test.ex:3 attempt to divide by 0") if the function returns -1, ignore the error Example: function oncrash(integer err_code,sequence info,sequence msg) if err_code=34 then--this error can be ignored in this program return -1 end if save_all_important_data() return 0 end function set_crash(routine_id("oncrash")) _________________________________________________ Threads in Eu 2.5? I think threads are needed in Euphoria. The example below would be fairly easy to use. Many programs would benifit from this. procedure new_thread(integer routine_id,sequence params,int priority) new_thread() starts the thread and returns imediatly. routine_id is the routine id for the procedure to run params is "params must be a sequence of argument values of length n, where n is the number of arguments required by the procedure. If the procedure does not take any arguments then params should be {}." (copied from manual: call_proc) priority is somthing like HIGH, LOW, NORMAL, ABOVENORMAL, ect procedure a() integer t t=time() for z=1 to 1000000+i do --do something that takes a lot of time here end for ?time()-t --a fairly high number end procedure procedure b(integer i) integer t t=time() for z=1 to 1000000+i do --do something that takes a lot of time here end for ?time()-t --a fairly high number end procedure integer tt tt=time() new_thread(routine_id("a"),{},ABOVENORMAL) new_thread(routine_id("b"),{rand(10)},LOW) ?time()-tt --would display a number near 0 because new_thread() returns imediatly __________________________________________________ I would like to be able to set the value of a variable like this: integer some_extremly_long_variable_name=82,another_extremly_long_variable_name=45 Instead of: integer some_extremly_long_variable_name,another_extremly_long_variable_name some_extremly_long_variable_name=82 another_extremly_long_variable_name=45 This would be much easeyer, especilly with long variable names. This is already used in constants, so why not with regular variables? __________________________________________________ Again, PLEASE take these into consideration! Tell me what you think.