Check-in [8b7522e1b5]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add some titles to the examples
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 8b7522e1b5f7f83e9b58d973113f9a565127e611d1ab51ddc4e5265662200a4b
User & Date: dkf 2018-05-27 10:35:37
Context
2018-05-27
10:43
A few more notes on exporting, and lengthen some very short paragraphs by combining them. check-in: a023e48805 user: dkf tags: trunk
10:35
Add some titles to the examples check-in: 8b7522e1b5 user: dkf tags: trunk
2018-05-26
09:49
Fixed typo in JO's name (SHAME!) check-in: 22823b2821 user: fbonnet tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to tip/500.md.

   308    308   A supporting introspector is also added, **info object creationid**, which
   309    309   returns the creation ID of any existing object. It also applies to classes.
   310    310   Again, note that creation IDs are _always_ system-allocated and are _never_
   311    311   guaranteed to be unique between interpreters, either in multiple processes or
   312    312   in the same thread or process; they are only ever locally unique.
   313    313   
   314    314   # Examples
          315  +
          316  +## Example: Private Variables and Tk
   315    317   
   316    318   This example shows a private variable linked to a Tk entry:
   317    319   
   318    320       oo::class create Editable {
   319    321           variable w;            # Allow subclasses to see this
   320    322           private variable val;  # Hide this from subclasses
   321    323   
................................................................................
   340    342       }
   341    343   
   342    344       Editable create field .e
   343    345       field trace {args {
   344    346           puts "field is now [field value]"
   345    347       }}
   346    348       field value "Set the contents"
          349  +
          350  +## Example: Private Methods and Code Complexity Management
   347    351   
   348    352   Ths is an example of private methods. It shows how private methods can be used
   349    353   to manage the complexity of a method without making its API (as exposed to
   350    354   either subclasses or the rest of Tcl) overly complex.
   351    355   
   352    356       oo::class create Modulator {
   353    357           # The exported interface to the class
................................................................................
   390    394       #        invoked from within
   391    395       #    "::oo::Obj15 modulate 5 6 7 8"
   392    396   
   393    397       catch {$m no.such.method} msg
   394    398       puts $msg
   395    399       # Prints something like:
   396    400       #    unknown method "no.such.method": must be destroy or modulate
          401  +
          402  +## Example: Private Methods and Variables Working Together
   397    403   
   398    404   This is a combined example of private methods and variables.
   399    405   
   400    406       oo::class create LabelEqual {
   401    407           constructor {label} {
   402    408               set [my varname label] $label
   403    409           }
................................................................................
   445    451       puts "one=[$expr1 value] two=[$expr2 value]"
   446    452       # Prints:
   447    453   	#    one=6 two=6
   448    454   
   449    455       puts [info vars [info object namespace $expr1]::*]
   450    456       # Prints something like:
   451    457   	#    {::oo::Obj13::11 : label} ::oo::Obj13::label
          458  +
          459  +## Example: Private Variable Naming and Creation IDs
   452    460   
   453    461   This example highlights the behaviour of private variables and
   454    462   `info object creationid`:
   455    463   
   456    464       # A simple introspection procedure for classes
   457    465       proc dumpinfo cls {
   458    466           puts "class ID of $cls is [info object creationid $cls]"