Ticket UUID: | 723677 | |||
Title: | ADD --> ::struct::tree -exists -- myTree | |||
Type: | RFE | Version: | None | |
Submitter: | davidhbigelow | Created on: | 2003-04-18 13:53:49 | |
Subsystem: | struct :: tree | Assigned To: | andreas_kupries | |
Priority: | 5 Medium | Severity: | ||
Status: | Deleted | Last Modified: | 2013-07-04 20:09:16 | |
Resolution: | Not Applicable Here | Closed By: | ||
Closed on: | ||||
Description: |
Currently there appears to be no way to detect if a ::struct::tree name exists without usign non-lib functions to capture what is availiable. CURRENT METHOD: if ![string match [info commands myTree] myTree] { ::struct::tree myTree } PROPOSED METHOD: if ![::struct::tree -exists -- myTree] { ::struct::tree myTree } We have found, when we are using the ::struct::tree as a central location for data (instead of arrays or lists), that we need to verify if the tree exists before we continue with other program logic. Since we have many procs referencing the same ::struct::tree, and any of them could be called at any time by the end user, we need to check to see if the ::struct::tree exists so we make sure to create it if it is not there. Even though there is a way to detect if the ::struct::tree exists using other Tcl commands - it would be easier and more complete to have this basic call in the ::struct::tree lib as a standard option. Any Questions? David Bigelow [email protected] | |||
User Comments: |
davidhbigelow added on 2003-04-18 22:52:59:
Logged In: YES user_id=664837 Good point about introspection. It did not hit me about that until I spent some time trying to figure out how to detect this so that I could avoid trying to create something that was already there and dealing with errors. However, if we have the ability to destroy a tree using the "myTree destory" - then we should be able to easily detect it's existance within the same command set and not have to jump to a more complicated string of commands to determine existance (e.g., [string equal [info commands myTree] myTree]) -- seems logical. Any Questions? Dave [email protected] andreas_kupries added on 2003-04-18 22:20:58: Logged In: YES user_id=75003 Confirming that we have nothing in the interface of tree for checking the existence of a tree ... This is a request I have think longer about, given that it is possible to check for existence of the object in other ways ... Do other object systems (like [incr Tcl], XOTcl, SNIT, ...) provide a class method or global command to check the existence of an object ? Or do they rely too on the introspection capabilities of Tcl ? |