1. "eval()" commands/crash callbacks/ect. for Euphoria 2.5?
- Posted by CoJaBo <cojabo at suscom.net> Jan 13, 2004
- 541 views
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. 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")) _________________________________________________ routine_id() for variables I would like to see a varible_id systym (like routine id) example: integer a,a_id a=3 a_id=var_id("a") ?get_var(a_id) --displays 3 set_var(a_id,4) --a now is 4 _________________________________________________________ and mayby a way to see if a var exists/is set Example: integer a,b a=1 ?is_var_set("a") --1 because a is set ?is_var_set("b") --0 because b exists, but is not set ?is_var_set("c") -- -1 because c doesn't exist ____________________________________________________________
2. Re: "eval()" commands/crash callbacks/ect. for Euphoria 2.5?
- Posted by "Hayden McKay" <hmck1 at dodo.com.au> Jan 13, 2004
- 465 views
----- Original Message ----- From: "CoJaBo" <cojabo at suscom.net> To: <EUforum at topica.com> Subject: "eval()" commands/crash callbacks/ect. for Euphoria 2.5? > In the first example, even if it did include the file, when it is bound > the line 'eval_commands = include incl_file.e' whould look like > 'eval_commands = (The entire file as a sequence or something). Personaly I like the current include method. all include file routines are declared at top level. In the second example, useing poke, peek and call can do the same thing. However I agree on the last example but I would like to see it more like this. n.b. Where 'exist' is a low level machine proc. integer a -- lots a code. -- more code. -- for some reason 'a' has still not been declared. if exist(a) then -- do something end if -- In this case 'exist' would return 'False'. I think a command like this could be used to catch unexpected runtime errors in AI Intelligence programming, unassighned variables etc.. and the boolen returned from 'exist' could be pased to a funtion to deal with the runtime error. > CoJaBo wrote: > 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. > > <Snip> > 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) > > > routine_id() for variables > I would like to see a varible_id systym (like routine id) > example: > integer a,a_id a=3 > a_id=var_id("a") > ?get_var(a_id) > --displays 3 > set_var(a_id,4) > --a now is 4 > --1 because a is set > > ?is_var_set("b") > --0 because b exists, but is not set > > ?is_var_set("c") > -- -1 because c doesn't exist > > > > TOPICA - Start your own email discussion group. FREE! > > > -- > Incoming mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.558 / Virus Database: 350 - Release Date: 2/01/04 > --- --
3. Re: "eval()" commands/crash callbacks/ect. for Euphoria 2.5?
- Posted by euphoric <euphoric at cklester.com> Jan 14, 2004
- 465 views
Kat wrote: >>Almost all other languages I've used had an "eval()" command, this would= >>=20 >>be very useful in Euphoria. >> >> >I agreed=20 with=20 you!!=20 Please=45 explain=60 this=50to RDS!!=98 >=74 >=-3456.2 >Kat=65 > > LOL, Kat. You so silly...