|
2008-04-05
| ||
| 04:53 | • Closed ticket [1863645fff]: Rename method constructors in C-API to avoid confusi... artifact: 8fcd7356b5 user: dkf | |
|
2008-01-06
| ||
| 22:23 | • Ticket [1863645fff]: 4 changes artifact: 1c0d0d9d6b user: dkf | |
|
2008-01-04
| ||
| 06:38 | • Ticket [1863645fff]: 4 changes artifact: 28c19e2d74 user: mpc_janssen | |
| 06:28 | • Ticket [1863645fff]: 4 changes artifact: 0b858c5377 user: mpc_janssen | |
|
2008-01-03
| ||
| 23:19 | • New ticket [1863645fff]. artifact: 2483419afc user: mpc_janssen | |
Rename method constructors in C-API to avoid confusion
Closed / Fixed1863645fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-01-03 23:19:06
Before starting I will define some terminology (which is similar to terminology in Smalltalk/Ruby/XOTcl and probably more) Object: everything is an object so classes and instances are also objects Class: A class can create instance objects and contains the behavior of the instances Instance: An instance is an object create by a class Instance method: A method that can be called on a instance of a class and which is defined in the class Object method: A method defined on a single object (either a class or an instance) Singleton/Self method: Equivalent to Object method Class/Static method: A method that is an object method of a class. This is a special case of the Object method if the object is also a class. Looking at the Tcl API, object methods are defined using self.method instance methods are defined using method Looking at the C-API object methods are defined using Tcl_NewMethod. instance methods are defined using Tcl_NewClassMethod notice how the name of the instance method function causes confusion with the definition of Class/Static method as defined above. A Class/Static method would be defined using Tcl_NewMethod on the class object. To avoid this confusion I think it would be benificial to rename the two commands to: Tcl_NewMethod -> Tcl_NewObjectMethod/Tcl_NewSelfMethod Tcl_NewClassMethod -> Tcl_NewInstanceMethod
mpc_janssenplain2008-01-04 06:28:49
Logged In: YES user_id=1463011 Originator: YES Maybe even (to bring the C-API in line with the Tcl API) Tcl_NewMethod -> Tcl_NewSelfMethod Tcl_NewClassMethod -> Tcl_NewMethod essentially inverting the role of Tcl_NewMethod from creating object methods to creating instance methods
mpc_janssenplain2008-01-04 06:38:31
Logged In: YES user_id=1463011 Originator: YES Also note that this follows the same design decision as for the Tcl API too make the most common operation (defining instance methods) the least verbose name.
dkfplain2008-01-06 22:23:59
Logged In: YES user_id=79902 Originator: NO I'm thinking in terms of just converting Tcl_NewMethod -> Tcl_NewObjectMethod Note that TclOO doesn't (and can't) support static methods without additional method types. I'm going to leave them to the aftermarket modders... :-)
dkfplain2008-04-05 04:53:52
Logged In: YES user_id=79902 Originator: NO Fixed for 0.2 Tcl_NewMethod -> Tcl_NewInstanceMethod Tcl_NewClassMethod -> Tcl_NewMethod Rationale: methods on classes are the most common case, and the case that most people understand "instinctively", and the other kind works on (object) instances. (I'll leave the "class method" concept alone for now; it's not clear to me now how it fits with the fundamental model that TclOO uses.)
Log in (anonymous is fine) to add a comment.