Question on ns_eval

8 views
Skip to first unread message

Sep Ng

unread,
Feb 14, 2013, 4:21:30 AM2/14/13
to aols...@googlegroups.com
Hello,

I've been looking into improve my development environment by using ns_eval to update all the TCL interps everytime I do changes on it. First off, it looks like I have to escape all the special TCL characters on ns_eval.  Is this the intended behaviour because I've seen many examples of people using ns_eval to do something like this:
ns_eval {source /somewhere/out/there/file.tcl}
but this has never worked for me (source seems to get confused with the [ and the ].

I did a test and ran:
ns_eval {ns_log notice {test me}}
which produced errors where there were too many ns_log arguments.  I was able to get it to work by doing this:
ns_eval {ns_log notice \{test me\}}

This leads me to believe that I have to escape every character that I use for ns_eval.

My second question is that some of my custom API calls don't seem to be recognized when running ns_eval.  I don't really have much of an explanation for what this could be.  If anyone has ideas and theories, I'm all ears.

Thanks!

William J. Webb

unread,
Feb 14, 2013, 1:33:26 PM2/14/13
to aols...@googlegroups.com
At the core, we use a slightly different version of:

#{{{ eval_source
#
proc eval_source { filename } {
if { [file exists $filename] } {
set err [catch { ns_eval [list source $filename] } result]
}
if { $err } {
ns_log notice eval_source ERROR: $result
}
} else {
error "file $filename does not exist."
}
}
#}}}

There are some wrappers around this to recurse through directories using patterns, ignore certain types of files, etc.

Note that "ns_eval is asynchronous and the script isn't immediately evaluated in the other interpreters until their next atalloc event".  E.g.: you run an ns_eval/source in one nscp, you won't see it reflected in a second concurrent nscp session.

Will

William J. Webb

unread,
Feb 14, 2013, 1:59:28 PM2/14/13
to aols...@googlegroups.com


On Thursday, February 14, 2013 12:33:26 PM UTC-6, William J. Webb wrote:
At the core, we use a slightly different version of:

Sep Ng

unread,
Feb 14, 2013, 5:48:58 PM2/14/13
to aols...@googlegroups.com
Thank you for the responses.  I'll conduct some tests.  The code I use to reload right now is:

eval namespace eval :: source $file

so on swtching to ns_eval, I thought to maybe skip the namespace eval.  With or without don't seem to make a difference, but I'll
continue to look into this.

Sep Ng

unread,
Feb 15, 2013, 2:08:57 AM2/15/13
to aols...@googlegroups.com
I think I figured out what's wrong.  Basically, I have a custom proc_doc that does its own things and remaps namespaces and apparently it was calling ns_eval on its own.  It looks like it was also confusing the braces because of the args on proc_docs.

I think I'm good now. :)
Reply all
Reply to author
Forward
0 new messages