variable_id

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

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu