You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Instead of hinting the compiler with comments how about if the same hinting is formally available through tsp::proc itself? If compilation fails tsp::proc can still generate a legal Tcl proc as it does now.
For example, change something like:
tsp::proc tsp_lrandom {list} {
#tsp::procdef var -args var
#tsp::compile assert
#tsp::int len which
set len [llength $list]
set which [expr {int(rand() * $len)}]
return [lindex $list $which]
}
to
tsp::proc tsp_lrandom {var list returning var} {
#tsp::int len which
set len [llength $list]
set which [expr {int(rand() * $len)}]
return [lindex $list $which]
}
This doesn't cover the variable declarations like "#tsp::int len which", and I can see problems with not using comments there and tsp::proc having to distinguish between hints and code. Maybe it could have a variable declaration section as an additional argument to tsp::proc, something like:
tsp::proc tsp_lrandom {var list returning var} {
int len which
} {
set len [llength $list]
set which [expr {int(rand() * $len)}]
return [lindex $list $which]
}
The text was updated successfully, but these errors were encountered:
This would make it more difficult to manually revert a tsp::proc to an uncompiled proc (such as for debugging purposes) by simply removing the "tsp::" part from the proc line.
That's a good point. If the proc arguments were kept in the normal style instead of adding the "returning" thing I was proposing but it still had the additional section with the variable declarations and whatnot then the fallback to a normal proc is super simple, where the tsp::proc definition is in "list", execute something like "proc [lindex $list 1] [lindex $list 2] [lindex $list 4]" and you've got your compatible fallback.
An idea for your consideration...
Instead of hinting the compiler with comments how about if the same hinting is formally available through tsp::proc itself? If compilation fails tsp::proc can still generate a legal Tcl proc as it does now.
For example, change something like:
to
This doesn't cover the variable declarations like "#tsp::int len which", and I can see problems with not using comments there and tsp::proc having to distinguish between hints and code. Maybe it could have a variable declaration section as an additional argument to tsp::proc, something like:
The text was updated successfully, but these errors were encountered: