tsp icon indicating copy to clipboard operation
tsp copied to clipboard

can't source in tsp proc file interactively but runs from the command line

Open lehenbauer opened this issue 9 years ago • 2 comments

If I run, like, "tclsh latlons.tcl", it works, but if I start Tcl interactively and do a "source latlons.tcl", I get some MD5 signatures output to the terminal and a traceback.

 % source latlons.tcl 
MD5 (.) = ea4246ce05c0fff0f9db6a66575db603
MD5 (.) = ea4246ce05c0fff0f9db6a66575db603
can't read "v::code(/usr/home/karl/src/tsp_examples/latlons.tcl)": no such variable
while evaluating {source latlons.tcl }

 % puts $errorInfo
can't read "v::code(/usr/home/karl/src/tsp_examples/latlons.tcl)": no such variable
    while executing
"dict get $v::code($file) result"
    (procedure "critcl::cresults" line 3)
    invoked from within
"critcl::cresults"
    (procedure "::tsp::lang_compile" line 45)
    invoked from within
"::tsp::lang_compile compUnit $compilable"
    (procedure "::tsp::compile_proc" line 72)
    invoked from within
"::tsp::compile_proc $scriptfile $name $argList $body"
    (procedure "tsp::proc" line 6)
    invoked from within
"tsp::proc fa_latlongs_to_distance {lat1 lon1 lat2 lon2} {
    #tsp::procdef double -args double double double double
    #tsp::compile assert
    #tsp::double ..."
    (file "latlons.tcl" line 6)
    invoked from within
"source latlons.tcl "
    ("eval" body line 1)
    invoked from within
"eval $LINE"

lehenbauer avatar Jul 29 '15 07:07 lehenbauer

It's running /sbin/md5 instead of doing whatever it's supposed to do.

lehenbauer avatar Jul 29 '15 08:07 lehenbauer

The problem is due to some interaction between critcl, up to and including 3.1.15, and tclreadline. If in my .tclshrc I don't require tclreadline then the problem doesn't happen.

I'm pretty sure the problem is in critcl/lib/critcl/critcl.tcl; there's a lot of trickery starting around line 30 to come up with a working md5, or, depending on how you look at it, a problem in tclreadline.

In my .tclshrc if I package require tclreadline then when I try to source in a tsp::proc interactively, I get:

 % source test.tcl
MD5 (.) = 45786b6b37b66944713676903928042e
MD5 (.) = 45786b6b37b66944713676903928042e
can't read "v::code(/usr/home/karl/src/tmp/tsp/test.tcl)": no such variable
while evaluating {source test.tcl}

...even if I don't define a tclreadline::prompt proc or run ::tclreadline::Loop.

lehenbauer avatar Aug 12 '15 14:08 lehenbauer