Skip to content
Tcl Source Code History Of Ticket 3bb3bcf2da
Login

History Of Ticket 3bb3bcf2da

Artifacts Associated With Ticket 3bb3bcf2da

  1. Ticket change [13ceb6c1d0] (rid 203733) by chrstphrchvz on 2022-09-06 04:40:55:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      I would like to add support for Tcl 8.7/9.0 to Tcl.pm, a wrapper for using Tcl from Perl: [https://github.com/gisle/tcl.pm/pull/42]. My understanding is that it intends to remain compatible with Tcl 8.4.
      
      The main difficulty I have encountered so far is updating its <tt>SvFromTclObj()</tt> function for converting a given Tcl value to a Perl value of similar type. (The <tt>fromObj()</tt> function in Python’s Tkinter serves a similar purpose.) It will need to accommodate types no longer being registered in newer Tcl; it seems the workaround is to create a <tt>Tcl_Obj *</tt> of the desired type and then get its <tt>typePtr</tt>, as mentioned in TIP 484, and already done in some cases by Tkinter.
      
      One part I am still trying to understand is how to handle boolean types. This is complicated not only by some confusion on what the expected behavior on the Perl side is (e.g. [https://github.com/gisle/tcl.pm/issues/47]), but also by the various changes since Tcl 8.4. From what I can tell, Tcl so far has had a registered "boolean" type <tt>tclBooleanType</tt> added in 8.4, then renamed to <tt>oldBooleanType</tt> in 8.5, and dropped in 9.0 (and 8.7 with <tt>TCL_NO_DEPRECATED</tt>); and it has had an unregistered "booleanString" type <tt>tclBooleanType</tt> since 8.5, but which is now going to be called "boolean" in 9.0 (this was also the briefly the case for Tcl 8.7 with <tt>TCL_NO_DEPRECATED</tt> from [8b366f71d8] until being reverted seemingly without comment in [https://core.tcl-lang.org/tcl/fdiff?v1=f96e8cd9d38020dc&v2=0fa368afdf3e734c|4f6d4a2b15]). I am not aware why "booleanString" is being renamed to "boolean" other than it possibly seeming strange to have "booleanString" and no other boolean type present. Is there an issue that prevents it remaining "booleanString" for compatibility?
      
      I would be curious if there is any further advice for adapting C library code for Tcl 8.7/9.0 not already given in TIPs 484/485/600, and if anyone is aware of examples I can refer to of older C code successfully updated for 8.7/9.0. TIP 484 mentions some affected programs, but those do not appear to be actively maintained. I am not aware of Tkinter already preparing for Tcl 8.7/9.0, and Ruby tcltk seems further behind (still contains handling for Tcl 8.3).
      
      There are probably other things I should ask Tcl for help in this effort, though I’m not yet sure sure exactly what.
      
    5. foundin initialized to: "trunk"
    6. is_private initialized to: "0"
    7. login: "chrstphrchvz"
    8. priority initialized to: "5 Medium"
    9. resolution initialized to: "None"
    10. severity initialized to: "Minor"
    11. status initialized to: "Open"
    12. submitter initialized to: "chrstphrchvz"
    13. subsystem initialized to: "10. Objects"
    14. title initialized to: "Adding support for 8.7/9.0 to Tcl.pm"
    15. type initialized to: "Support"
  2. Ticket change [3c993fef92] (rid 203734) by chrstphrchvz on 2022-09-06 04:41:15:

    1. foundin changed to: "core-8-branch, trunk"
    2. login: "chrstphrchvz"
    3. mimetype: "text/plain"
  3. Ticket change [0b662a2833] (rid 203736) by jan.nijtmans on 2022-09-06 07:12:10:

    1. assignee changed to: "jan.nijtmans"
    2. icomment:
      > One part I am still trying to understand is how to handle boolean types
      
      Well, having a short look at the code, this won't work for your case:
      
      <pre>
          Tcl_NewBooleanObj(0);
      </pre>
      
      The reason: this will create an integer object, not a boolean one. If you want a boolean, do:
      
      <pre>
          Tcl_Obj boolObj = Tcl_NewStringObj("true", );
          int value;
          Tcl_GetBooleanFromObj(NULL, boolObj, &value);
      </pre>
      
      Then you can be sure that boolObj->typePtr will be the typePtr you want.
      
      The reason for the change is that in Tcl 8.7, the boolean values is stored in internalRep->longValue, in Tcl 9.0 it's stored in internalRep->wideValue (making it the same as for integers). External code should not assume anything about the internal representation, but code that does should still work in Tcl 8.7. Using "Tcl_GetBooleanFromObj" should do the trick, without assuming anything about the internal representation of booleans.
      
      Hope this helps! Feel free to ask more
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  4. Ticket change [2cb97687dd] (rid 204628) by chrstphrchvz on 2022-09-22 22:27:16:

    1. icomment:
      Thanks for suggesting an approach for getting the boolean type. I get the impression one should not care what Tcl calls string (non-numeric) boolean values, but I would still like to request that "booleanString" please not be renamed to "boolean" to avoid/reduce confusion for maintainers of existing code.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  5. Ticket change [3463030d4b] (rid 206945) by chrstphrchvz on 2022-11-17 19:55:29:

    1. icomment: "Related: [b5bd08df8d61]"
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [c3199eae96] (rid 211164) by chrstphrchvz on 2023-03-29 10:55:32:

    1. icomment:
      <blockquote>…I would still like to request that "booleanString" please not be renamed to "boolean" to avoid/reduce confusion for maintainers of existing code.</blockquote>
      
      Tkinter being one affected example (although changing their code to use the idiom suggested here is likely still an option): [https://github.com/python/cpython/blob/7559f5fda94a/Modules/_tkinter.c#L1201]
      
      I want to make sure I understand the relevance of TIP 568 to a wrapper. TIP 568 warns: “Most callers of <tt>Tcl_GetByteArrayFromObj</tt> are probably buggy”. But maybe the use case of a wrapper is an exception: it only ever wants to use <tt>Tcl_GetByteArrayFromObj()</tt> to retrieve values which are already of "bytearray" type. Is it true that if a Tcl value is already of type "bytearray", then both <tt>Tcl_GetByteArrayFromObj()</tt> and <tt>Tcl_GetBytesFromObj()</tt> behave the same and do not return <tt>NULL</tt>? It would be preferable to continue using <tt>Tcl_GetByteArrayFromObj()</tt> to maintain compatibility with 8.6 and earlier.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [11cfccda5f] (rid 211175) by jan.nijtmans on 2023-03-29 16:53:42:

    1. icomment:
      > Is it true that if a Tcl value is already of type "bytearray", then both Tcl_GetByteArrayFromObj() and Tcl_GetBytesFromObj() behave the same and do not return NULL?
      
      Yes, that's true
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [c483acbf99] (rid 213031) by chrstphrchvz on 2023-04-16 15:36:33:

    1. icomment:
      I am now looking into contributing similar changes to Tkinter: [https://github.com/python/cpython/issues/103194]
      
      I am trying to understand how obsolete registered types in 8.7, i.e. "int" on 32-bit systems and Tcl 8.4 "boolean", should be handled. Even though Tcl itself will never create values with obsolete types, is there some case I am overlooking which requires wrappers to still be able to recognize values with these types? The only possibility I can think of is if some C code out there (e.g. extensions) tries to create values with these types anyway (by setting <tt>objPtr-&gt;typePtr</tt> to a <tt>Tcl_ObjType *</tt> obtained from <tt>Tcl_GetObjType()</tt> as well as manually setting <tt>objPtr-&gt;internalRep</tt>), even though such code is likely broken under 9.0.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
    4. title changed to: "Adding support for 8.7/9.0 to Tcl.pm, Tkinter"
  9. Ticket change [36a7c9f358] (rid 256760) by serhiy.storchaka on 2026-09-20 11:18:12:

    1. icomment:
      For the record: Tkinter was adapted in [https://github.com/python/cpython/pull/103846|python/cpython#103846] (Python 3.12.4 and 3.13), using the approach suggested here: the "boolean", "bytearray" and "int" types are taken from the typePtr of a freshly created value when Tcl_GetObjType() returns NULL. Python 3.16 ([https://github.com/python/cpython/issues/153513|python/cpython#153513]) goes further and recognizes types which are not registered at all ("bignum", "pixel", "index", "window", "nsName", "parsedVarName", ...) by <tt>typePtr->name</tt> on first encounter, caching the pointer. This works without registration, but the wrapper would be simpler and faster if these types were registered (see [b5bd08df8d]). Python 3.14 ships with Tcl/Tk 9.0.4 on Windows.
      
      Tcl.pm 1.50 also supports Tcl 9.
      
    2. login: "serhiy.storchaka"
    3. mimetype: "text/x-fossil-wiki"