Skip to content
Tcl Source Code View Ticket
Login

View Ticket

copied object member variable confusion

Closed / Fixed3609693fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 13 years ago
Descriptionplain2013-04-01 13:41:41
In the following script, $obj2 thinks the value of its $var1 is "val1"


namespace import oo::*
set obj [object new]
objdefine $obj variable var1 
objdefine $obj method m {} {
    set var1 val1
}
objdefine $obj method get {} {
    return $var1
}

$obj m
$obj get
set obj2 [oo::copy $obj]
${obj2}::my eval {
    set var1 val2
}
puts [$obj2 get]
dkfplain2013-04-01 23:46:05
Looks like there's a cached reference to the variable in the method implementation, which is indeed the case because that's how variable references in object-specific methods are bound. The method cloner needs work...
dkf Ticket [3609693fff]: 5 changes [History diff]2013-08-03 19:21:51
dkfwiki2013-08-21 09:38:47

Committed a test to branch bug-3609693, but the code I've got to try and fix this crashes quite a distance away; I'm doing something wrong, but I don't know what.

dkfhtml2013-09-09 13:37:24

Ah! Needed to strip the internal representation from the body to prevent some strange things from happening. Fixed now.

dkfhtml2013-09-09 14:02:05

Damn. This breaks itcl completely.

dkfhtml2013-09-09 14:13:42

False alarm; that crash happens without this change too. Whatever's going on, it's not this.

Log in (anonymous is fine) to add a comment.