Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2014-01-27
12:01 • Closed ticket [9d0cfbc51e]: method create is handled very differently from oth... artifact: f1cb51b4c1 user: dkf
00:45 • New ticket [9d0cfbc51e]. artifact: 28965db927 user: cmcc

method [create] is handled very differently from other methods

Closed / Invalid9d0cfbc51e3b6281aae4447c3603591dc0ec35d9Created 13 years agoUpdated 13 years ago
Descriptionplain2014-01-27 00:45:04
From the following:

oo::class create creator {
    method moop {args} {
	puts stderr "moop"
    }
    method create {args} {
	puts stderr "create"
    }
    constructor {args} {
	puts stderr "constructed"
    }
}

creator create fred
fred moop

I get the output:

constructed
moop

Where I would have expected to see 'create' ... this represents a pretty significant change to the relationship between oo::class and the rest over earlier tcloo versions, and also suggests that "create" has become something of a reserved word within tcloo.

Is there some documentation for this behaviour?

Colin
dkfhtml2014-01-27 12:01:47

Everything looks fine to me, and I've not done anything odd here for ages.

% oo::class create creator {
    method moop {args} {
	puts stderr "moop"
    }
    method create {args} {
	puts stderr "create"
    }
    constructor {args} {
	puts stderr "constructed"
    }
}
::creator
% creator ?
unknown method "?": must be create, destroy or new
% creator create fred
constructed
::fred
% fred ?
unknown method "?": must be create, destroy or moop
However, it should be noted that the create that you normally see is the one provided by the class object, not the instance object. It's actually a normal method that is implemented in C and defined on the oo::class class.
% info class methods oo::class
create new
% info class methods oo::class -all
create destroy new
(The -all means use the superclass method implementations as well, so it picks it up from the oo::object class.)

Metaclasses are funky stuff.

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