Check-in [96cdaa7bf6]

Login

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

Overview
Comment:Untabify for consistent indentation
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk | minor change
Files: files | file ages | folders
SHA3-256: 96cdaa7bf66087cd6d6a0868f74445480f735ab322482a1e892a45124263be1e
User & Date: dkf 2018-05-19 10:49:14.937
Context
2018-05-19
10:51
Added comment to highlight a (minor) syntactic feature check-in: 3a4f7e4abc user: dkf tags: trunk
10:49
Untabify for consistent indentation check-in: 96cdaa7bf6 user: dkf tags: minor change, trunk
10:48
Added an example check-in: e6ade010a0 user: dkf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/500.md.
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
Again, note that creation IDs are _always_ system-allocated and are _never_
guaranteed to be unique between interpreters, either in multiple processes or
in the same thread or process; they are only ever locally unique.

# Example

    oo::class create LabelEqual {
		constructor {label} {
			set [my varname label] $label
		}
        private {
		    variable label
			method getLabel {} {
			    return $label
			}
		}
		method equals {other} {
			expr {$label eq [$other getLabel]}
		}
	}

	oo::class create Evaluated {
		superclass LabelEqual
		# Poorly chosen variable name! Happens too easily in real life
		variable label
		constructor {expression} {
			next $expression
			set label [expr $expression]
		}
	    method value {} {
			return $label
		}
	}

	set expr1 [Evaluated new {1 + 2 + 3}]
	set expr2 [Evaluated new {3 + 2 + 1}]
	puts "one is two? [$expr1 equals $expr2]"
	# Prints: one is two? 0
	puts "one=[$expr1 value] two=[$expr2 value]"
	# Prints: one=6 two=6
	puts [info vars [info object namespace $expr1]::*]
	# Prints something like: {::oo::Obj13::11 : label} ::oo::Obj13::label
	catch {$expr2 getLabel} msg
	puts $msg
	# Prints: unknown method "getLabel": must be destroy, equals or value

# Implementation

See the [`tip-500` branch](https://core.tcl.tk/tcl/timeline?r=tip-500).

# Copyright








|
|
|

|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|







275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
Again, note that creation IDs are _always_ system-allocated and are _never_
guaranteed to be unique between interpreters, either in multiple processes or
in the same thread or process; they are only ever locally unique.

# Example

    oo::class create LabelEqual {
        constructor {label} {
            set [my varname label] $label
        }
        private {
            variable label
            method getLabel {} {
                return $label
            }
        }
        method equals {other} {
            expr {$label eq [$other getLabel]}
        }
    }

    oo::class create Evaluated {
        superclass LabelEqual
        # Poorly chosen variable name! Happens too easily in real life
        variable label
        constructor {expression} {
            next $expression
            set label [expr $expression]
        }
        method value {} {
            return $label
        }
    }

    set expr1 [Evaluated new {1 + 2 + 3}]
    set expr2 [Evaluated new {3 + 2 + 1}]
    puts "one is two? [$expr1 equals $expr2]"
    # Prints: one is two? 0
    puts "one=[$expr1 value] two=[$expr2 value]"
    # Prints: one=6 two=6
    puts [info vars [info object namespace $expr1]::*]
    # Prints something like: {::oo::Obj13::11 : label} ::oo::Obj13::label
    catch {$expr2 getLabel} msg
    puts $msg
    # Prints: unknown method "getLabel": must be destroy, equals or value

# Implementation

See the [`tip-500` branch](https://core.tcl.tk/tcl/timeline?r=tip-500).

# Copyright