proc foo {var} {
  if {$var == 10} {
    return 1
  } else {
    return 0
  }
}

ns_share shvar
set shvar 10
set plainvar 20
if {[foo $shvar] || [foo $plainvar]} {
  ns_return 200 text/plain "had a foo"
} else {
  ns_return 200 text/plain "no foos here"
}

I realize that when calling foo I could dereference the nsv, but it
gets even more klunky if foo has to set one of its arguments.  How
does it know if it's an nsv or not?  You have to pass a flag with
every variable passed by reference and have two sets of code in the
routine: one to set the argument if it's an nsv, and another to set it
if it's a real variable.  That's a huge kludge IMO.  I know "a good
program wouldn't change the value of arguments".  But in practice it
is useful and it happens.  Plus, now that we have 90K lines of TCL
using ns_shares, changing them to use nsv's would be a real nosebleed.

Jim

>
> On Wednesday, October 17, 2001, at 10:23 AM, Jim Wilcoxson wrote:
> > We don't use nsv's - IMO that programming model is broken because
> > regular TCL constructs can't be used on nsv's.
> I probably missed a memo or something, but can you tell me what you have
> in mind here?
>
> Pete.
>

Reply via email to