TIP 630: TclOO commands > 2^31 (for 8.7)

    Author:        Jan Nijtmans <[email protected]>
    State:         Final
    Type:          Project
    Vote:          Done
    Created:       05-07-2022
    Tcl-Version:   8.7
    Keywords:      Tcl
    Tcl-Branch:    tcloo-64bit
    Vote-Summary   Accepted 3/0/1
    Votes-For:     JN, KBK, KW
    Votes-Against: none
    Votes-Present: FV


This TIP proposes 3 new functions for TclOO:

Those functions do the same as Tcl_MethodIsType/Tcl_NewInstanceMethod/Tcl_NewMethod, but their typePtr argument is now of type const Tcl_MethodType2 *. Those new types can handle more than 2^31 command line arguments when used in Tcl 9.0.

Since the Tcl core cannot handle commands with more than 2^31 elements yet, this - for now - is of limited usability: The core should first be extended to handle this everywhere, which is a massive amount of work. Therefore, I am choosing to submit this part separately, so it can be used in Tcl 8.7 as well. A later TIP #626 (for Tcl 9.0), which makes the actual transition making it really useful, can then decided upon separately. Also, if the API is decided upon, the actual transition could even be delayed until Tcl 9.1: As long as the API stays the same, it is considered an upwards compatible change, no matter how it is handled internally.


The following new functions are defined:

The definitions of the new types are:

    typedef int (Tcl_MethodCallProc2)(void *clientData, Tcl_Interp *interp,
           Tcl_ObjectContext objectContext, Tcl_Size objc, Tcl_Obj *const *objv);
    typedef struct {
        int version;               /* Structure version field. Always to be equal
                                    * to TCL_OO_METHOD_VERSION_2 in
                                    * declarations. */
        const char *name;          /* Name of this type of method, mostly for
                                    * debugging purposes. */
        Tcl_MethodCallProc2 *callProc;
                                   /* How to invoke this method. */
        Tcl_MethodDeleteProc *deleteProc;
                                   /* How to delete this method's type-specific
                                    * data, or NULL if the type-specific data
                                    * does not need deleting. */
        Tcl_CloneProc *cloneProc;  /* How to copy this method's type-specific
                                    * data, or NULL if the type-specific data can
                                    * be copied directly. */
    } Tcl_MethodType2;
Note that the objc argument (Tcl_MethodCallProc2) changed from int to Tcl_Size. and the callProc field (Tcl_MethodType2) changed from Tcl_MethodCallProc * to Tcl_MethodCallProc2 *.

Two new constants are defined:


After TIP #665 was accepted, a lot of functions changed from using size_t to Tcl_Size parameters. In order to prevent confusion, this change has been adapted in the TIP text above as well.


See branch tcloo-64bit

There also is a tcloo-64bit branch for Itcl, which demonstrates this TIP (and TIP #627 too).


The proposed change is 100% source and binary compatible with Tcl 8.6.


This document has been placed in the public domain.