Skip to content
Tcl Source Code Artifact [2684b91cfc]
Login

Artifact [2684b91cfc]

Artifact 2684b91cfc128996809c0ec34c99677aad5aea18928ae424297c30067ed48d5e:

Ticket change [2684b91cfc] - Ticket [b5bd08df8d61b4ea|b5bd08df8d] <i>The &quot;int&quot; type registration should be restored.</i> status still Open with 3 other changes by jan.nijtmans on 2022-11-18 10:36:10.
D 2022-11-18T10:36:10.051
J icomment >\sSo\sextensions\shave\smade\suse\sTcl_GetObjType\sto\sguess\sthe\stype\sand\soffer\sa\s"casting"\smechanism\sthat\sonly\sneeds\sto\sbe\sused\sin\sspecial\scases.\sThis\shas\sworked\ssurprisingly\swell\sin\spractice.\r\n\r\nThe\s'correct'\sway\sto\scheck\sfor\sa\sspecific\stype\sin\sTcl\sis\sto\suse\sfunctions\slike\sTcl_GetIntFromObj(),\sTcl_GetWideIntFromObj(),\sTcl_GetBignumFromObj(),\sand\ssee\swhether\sthey\sreturn\sTCL_OK\sor\snot.\sSince\sTcl\suses\sducktyping\s(anything\slooking\slike\san\sinteger\sis\sreally\san\sinteger),\sthe\sconcept\sis\sdifferent\sfrom\sother\slanguages.\sE.g.\sin\sjava,\s'5'\sis\sa\scharacter,\s"5"\sis\sa\sstring\sand\s5\sis\san\sinteger.\sIn\sTcl,\sthere\sis\sno\sdistinction,\s5\scan\sbe\sa\sstring,\sa\sinteger,\sa\swideInteger,\sa\sbugnum,\seven\sa\slist\s(with\sjust\sa\ssingle\selement).\sYou\scannot\sbe\ssure,\suntil\syou\scall\sa\sfunction\sto\scheck\sthat,\sit's\sobjType\sjust\ssays\ssomething\sabout\show\sit\sis\sstored\sinternally\sat\sthe\smoment.\r\n\r\nThe\sextension\sI\shave\sseen,\scheck\sthe\sobjType\sjust\sas\soptimization:\sIf\san\sobject\shas\ssome\stype\salready,\syou\sdon't\sneed\sto\scall\sTcl_GetXXXFromObj()\sto\sknow\sthe\sreal\stype.\sIn\sTcl\s8.6,\sasking\sfor\sthe\stype\sof\s5,\sit\smight\sbe\sNULL,\sor\stclListType\sor\stclIntType\sor\stclWideIntType.\sIn\sTcl\s8.7,\sit\swill\snever\sreturn\stclIntType\s(since\sit\suses\stclWideIntType\sinternally\severywhere).\sIn\sTcl\s9.0,\stclIntType\sis\sgone,\sbut\stclWideIntType\sis\snamed\s"int"\sfor\smaximum\scompatibility.\r\nYes,\sit\smeans\sthat\sextensions\sneed\sto\sbe\sadapted,\shopefully\sthey\sstart\susing\sTcl_GetIntFromObj()/Tcl_GetWideIntFromObj()/Tcl_GetBignumFromObj()\sto\scheck\sfor\sthe\srealy\stype\sin\sstead\sof\sdepending\son\sthe\sobjType.\r\n\r\nThat's\smy\s2c
J login jan.nijtmans
J mimetype text/x-fossil-wiki
K b5bd08df8d61b4ea9bf0cc885f790b367c430a9f
U jan.nijtmans
Z 96d7e951d4341433138e42e5e32a5d4a