TclOO Package

Check-in [395e16c285]
Login

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

Overview
Comment:Added file used for making pretty release notes for SourceForge.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 395e16c285c2ca58e757dcbf5d5844fa0a17ce9c
User & Date: dkf 2013-09-27 09:01:51.567
Context
2013-09-28
22:54
typo; spotted by stu check-in: f3dd9d97ab user: dkf tags: trunk
2013-09-27
09:01
Added file used for making pretty release notes for SourceForge. check-in: 395e16c285 user: dkf tags: trunk
2013-09-26
21:58
Fixed the changelog check-in: 58c315430b user: dkf tags: corresponds-to-Tcl8.6.1, release, release-1.0.1, trunk
Changes
Unified Diff Ignore Whitespace Patch
Added README.md.


























































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
Release of TclOO Version 1.0.1
==============================

This officially corresponds to the version of TclOO that is included with Tcl
8.6.1, except for features (notably coroutine support) that require the 8.6
runtime and not-officially-observable differences like the degree of bytecode
compilation support.

TclOO: An Object System for Tcl
===============================

TclOO is an object system for Tcl that has been designed to provide high
performance while still allowing as much flexibility as possible, and to be a
core for other object systems. It supports a single-rooted class-based object
system where classes are themselves subclassable objects, with multiple
inheritance, mixins, procedure-like and forwarded methods, filter methods,
dynamic reconfiguration, etc.

It does not come with a large class library, and it does not force its use
upon user scripts.

The heritage of TclOO can be traced back to a number of other object systems,
notably including XOTcl, incr Tcl, and Snit. It also draws on experience with
object systems in other languages like C++, Java and Ruby (despite being
somewhat different from each of them).

Changes in TclOO 1.0.1
----------------------
Bugfixes for:

* <http://core.tcl.tk/tcl/info/9d61624b3d>

* <http://core.tcl.tk/tcl/info/3603695>

No API changes.

For a full description of all changes, see:

* <http://core.tcl.tk/tcloo/timeline?from=release-1.0&to=release-1.0.1>

Building
--------

TclOO 1.0.1 uses the TEA3 build system. These instructions are known to work
on Linux, OSX and Windows (with msys installed).

1. Make sure you have a source distribution of Tcl 8.5 somewhere; you will
   need it to build TclOO. (Note that this functionality is incorporated
   directly into Tcl 8.6; you do not need this package with that version.)

2. Run the configure shell script in this directory. You may well want to
   use the `--with-tcl` option to tell the script where to find Tcl's build
   descriptor. Using the `--prefix` option to specify where to install the
   built version is also often useful.

3. Run '`make`'.

4. Run '`make test`'. There should be no test failures, but some memory stress
   tests are not run under normal conditions as they require a special build
   of Tcl.

5. Run '`make install`'. You might need to get elevated privileges to do this
   (e.g. by using '`sudo`') to install in a shared area.

Support
-------

Please file bug reports, feature requests and patches on core.tcl.tk under the
Tcl package. <http://core.tcl.tk/tcl/tktnew> To ensure attention from the
relevant maintainer, please use "35. TclOO Package" for the Category field.
Remember, it is better to file a bug report twice than not at all!

Basic Usage of TclOO
====================

Adding up values with TclOO:

    oo::class create summation {
        variable v
        constructor {} {
            set v 0
        }
        method add x {
            incr v $x
        }
        method value {} {
            return $v
        }
        destructor {
            puts "Ended with value $v"
        }
    }
    set sum [summation new]
    puts "Start with [$sum value]"
    for {set i 1} {$i <= 10} {incr i} {
        puts "Add $i to get [$sum add $i]"
    }
    summation destroy

Toasting bread with events and TclOO:

    oo::class create Toaster {
        variable toasting time
        constructor {toastingTime} {
            set time $toastingTime
            set toasting ""
        }
        method toast {breadProduct} {
            if {$toasting ne ""} {
                error "already toasting something"
            }
            set toasting [after $time [namespace code [list \
                    my Toasted $breadProduct]]]
            puts "toasting $breadProduct for you"
        }
        method Toasted {breadProduct} {
            puts "toasted the $breadProduct"
            set toasting ""
        }
        destructor {
            after cancel $toasting
        }
    }
    
    Toaster create quickToaster 30000 ;  # 30 seconds only
    quickToaster toast crumpet
    
    after 40000 {set done ok}
    vwait done ;                         # Run the event loop
    
    quickToaster destroy ;               # Delete the object

Compatibility Warnings
======================
Names of classes, methods or variables that begin with a hyphen can now cause
issues with some definitions (i.e., they are reserved to slotted operations).
The fix is to precede the name with a "`--`" argument in the problem definition;
see the `oo::define` documentation for the affected definitions.

Method names that are proper multi-element lists are reserved for future
functionality.