1. variable_id

Sooooo... here's how to implement variable_id(), in case anyone was curious. Posted to a gist because it's kinda long. Most of it's actually documentation and exposition on how/why the code does what it does.

The killer feature is actually print_var() which makes it really easy to do printf-style debugging! (Because we know everyone secretly loves printf-style debugging.)

include varid.e 
 
procedure main() 
 
    integer one = 1 
    atom two = 0.2 
    sequence three = {one,two,"three"} 
    object four 
 
    print_var( "one" )   -- 1 
    print_var( "two" )   -- 0.2 
    print_var( "three" ) -- {1,0.2,"three"} 
    print_var( "four" )  -- <no value> 
    print_var( "five" )  -- <not found> 
 
end procedure 
 
main() 

-Greg

new topic     » topic index » view message » categorize

2. Re: variable_id

I think this other function was brought up twice, only once by me, many years ago.

Some background info.. .. ..

When assigning a value to a variable, it (can) run thru a user type check. I used that feature to make global vars, shared between programs. The most difficult part was that the type functions don't seem to know the name of the variable they are checking the data's type for. I had to use a preprocessor to rename every global var, and give it a unique typecast, and each type check was unique to and serviced only one variable.

If there was a hook similar to what type() has in the assignment to variables, a user could write the name and data (and anything else, 3-keyed "maps" anyone?) to ordinary linked lists (or other database) , and query that in any way Euphoria already allows. As well, the list could be saved between program runs, and preloaded with a simple file read.

The new function would be set up by the user, specifying the sequence name used and format and any other data and function calls desired. Such as possibly writing the data to another program.

Kat

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu