RE: "eval()" commands/crash callbacks/ect. for Euphoria 2.5?
- Posted by CoJaBo <cojabo at suscom.net> Jan 15, 2004
- 377 views
Okay, I'll try once more (Am I going crazy or are there "=##"s every were?!?): I beleive that at least the first two should be added to Eu 2.5. Anyone else agree? Please take them 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. 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 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 5 for divide by 0,see below) Example: integer a,global_type sequence eval_commands eval_commands=" include incl_file.e--should allow including(This could be used --instead of complex "dynamic includeing" libraries) if a then ?a end if" a=7 var_type=1 ?eval(eval_commands,global_type,0) Displays: 7(value of a) 0(eval encountered no errors) ____________________________________________________________ Crash callback A way to setup a callback function would allow programs to save user data before exiting with ex.err 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")) _________________________________________________ CoJaBo wrote: > > > I beleive that at least the first two should be added to Eu 2.5. > Anyone else agree? > > Please take them 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. > > 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 > > 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=20 > returns an error=20 > code(like 5 for divide by 0,see below) > > > Example: > integer a,global_type > sequence eval_commands > > eval_commands=3D" > include incl_file.e--should allow including(This could be used=20 > --instead of complex "dynamic includeing" libraries) > if a then > ?a > end if" > > a=3D7 > var_type=3D1 > > ?eval(eval_commands,global_type,0) > Displays: > 7(value of a) > 0(eval encountered no errors) > > ____________________________________________________________ > Crash callback > A way to setup a callback function would allow programs to save user=20 > data before exiting > with ex.err > > 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,=20 > 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=3D34 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")) > > _________________________________________________ > Kat wrote: > >=20 > >=20 > > On 14 Jan 2004, at 1:27, CoJaBo wrote: > >=20 > > >=20 > > >=20 > > > I don't see why Euphoria can't support at least the first two. > > >=20 > > > A way to recvor from errors is almost absolutly nessescery in=20 > > > programs=3D20 > > > that have a lot of user data when they might crash.(like Win32Lib IDE) > > >=20 > > > Almost all other languages I've used had an "eval()" command, this=20 > > > would=3D > > > =3D20 > > > be very useful in Euphoria. > >=20 > > I agreed=3D20 with=3D20 you!!=3D20 Please=3D45 explain=3D60 this=3D50to > > R= > DS!!=3D98 > > =3D74 > > =3D-3456.2 > > Kat=3D65 > >=20 > >=20 <snip>