I am creating a Tcl-NAP object with the following statement:
set in [nap_get hdf $info(hdffile) "$SDS"]
where "in" is a namespace variable (call it namespace "foo"). Then I use it later to view specific data points in the 3-d array:
set ::result [[nap "foo::in($::xval, $::yval, 0)"]]
But I can only do this once. After one use, I get the error "Nap_Index: Left argument is unknown NAO ID ::NAP::15-14". So it looks like it's deleting my object. But I've got it referenced!
Does you know what might be going on here?
Thanks,
Eric
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry about not replying, I had expected Harvey to pick this one up. Numerical Array Objects (NAOs) have a reference count. When the reference count gets to 0 the object kills itself. In your example there is no reasonable way to increment the reference count on the NAO created by your nap command. The NAO says "hey, I have been created so someone wants me but I have a zero reference count. If no one increments my reference count I will kill myself after one operation"
What you should do is nap result = [[nap "foo.....]]
in this case the nap command manages reference counts so that the result variable points to the NAO and the NAO reference count is incremented. A way around this might have been for us to overlay a new version of set which understood NAOs and did this in the context of the set command.
The bottom line here is that nap is not perfectly integrated with tcl and this is a nasty issue you can trip up on. The other issue to watch is that the Tcl parser gets first look at any expressions so if there are constructs that you want the nap parser to see make sure they are protected by ". {s are often removed in the first (and only) parse by Tcl. so
nap x = {1 2 3} will not generate a vector 1 2 3
but
nap x ={1 2 3}
and
nap x = "{1 2 3}
because the { is protected from the Tcl parser by the = and " respectively.
Hope this helps
cheers
Peter
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I am creating a Tcl-NAP object with the following statement:
set in [nap_get hdf $info(hdffile) "$SDS"]
where "in" is a namespace variable (call it namespace "foo"). Then I use it later to view specific data points in the 3-d array:
set ::result [[nap "foo::in($::xval, $::yval, 0)"]]
But I can only do this once. After one use, I get the error "Nap_Index: Left argument is unknown NAO ID ::NAP::15-14". So it looks like it's deleting my object. But I've got it referenced!
Does you know what might be going on here?
Thanks,
Eric
Sorry about not replying, I had expected Harvey to pick this one up. Numerical Array Objects (NAOs) have a reference count. When the reference count gets to 0 the object kills itself. In your example there is no reasonable way to increment the reference count on the NAO created by your nap command. The NAO says "hey, I have been created so someone wants me but I have a zero reference count. If no one increments my reference count I will kill myself after one operation"
What you should do is nap result = [[nap "foo.....]]
in this case the nap command manages reference counts so that the result variable points to the NAO and the NAO reference count is incremented. A way around this might have been for us to overlay a new version of set which understood NAOs and did this in the context of the set command.
The bottom line here is that nap is not perfectly integrated with tcl and this is a nasty issue you can trip up on. The other issue to watch is that the Tcl parser gets first look at any expressions so if there are constructs that you want the nap parser to see make sure they are protected by ". {s are often removed in the first (and only) parse by Tcl. so
nap x = {1 2 3} will not generate a vector 1 2 3
but
nap x ={1 2 3}
and
nap x = "{1 2 3}
because the { is protected from the Tcl parser by the = and " respectively.
Hope this helps
cheers
Peter