This manual page is for Mac OS X version 10.6.3

If you are running a different version of Mac OS X, view the documentation locally:

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • For more information about the manual page format, see the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Reference Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.



local(n)                                         [incr Tcl]                                         local(n)



____________________________________________________________________________________________________________

NAME
       local - create an object local to a procedure

SYNOPSIS
       itcl::local className objName ?arg arg ...?
____________________________________________________________________________________________________________


DESCRIPTION
       The  local  command  creates  an [incr Tcl] object that is local to the current call frame.  When the
       call frame goes away, the object is automatically deleted.   This  command  is  useful  for  creating
       objects that are local to a procedure.

       As  a  side  effect, this command creates a variable named "itcl-local-xxx", where xxx is the name of
       the object that is created.  This variable detects when the call frame is destroyed and automatically
       deletes the associated object.


EXAMPLE
       In the following example, a simple "counter" object is used within the procedure "test".  The counter
       is created as a local object, so it is automatically deleted each time the procedure exits.  The puts
       statements  included  in the constructor/destructor show the object coming and going as the procedure
       is called.
              itcl::class counter {
                  private variable count 0
                  constructor {} {
                      puts "created: $this"
                  }
                  destructor {
                      puts "deleted: $this"
                  }

                  method bump {{by 1}} {
                      incr count $by
                  }
                  method get {} {
                      return $count
                  }
              }

              proc test {val} {
                  local counter x
                  for {set i 0} {$i < $val} {incr i} {
                      x bump
                  }
                  return [x get]
              }

              set result [test 5]
              puts "test: $result"

              set result [test 10]
              puts "test: $result"

              puts "objects: [itcl::find objects *]"


KEYWORDS
       class, object, procedure



itcl                                                                                                local(n)

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation to the Tcl project.
Bug reports
Report bugs in the functionality of the described tool or API to Apple through Bug Reporter and to the Tcl project through their bug reporting page.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.

Did this document help you? Yes It's good, but... Not helpful...