"eval()" commands/crash callbacks/ect. for Euphoria 2.5?

new topic     » topic index » view thread      » older message » newer message

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
____________________________________________________________

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu