<i>Tcl_DictObjPut() - poor usability</i> status still Open with 3 other changes
by
.
D 2024-05-25T12:44:56.684
J icomment The\sbranch\s[more-dict-c-funcs](https://core.tcl-lang.org/tcl/timeline?r=more-dict-c-funcs)\shas\ssome\sideas\son\sthis.\r\n\r\n##\sBranch\sDescription\r\n\r\nThe\sbranch\shas\sfour\snew\sfunctions:\r\n\r\n\tint\tTclDictGet(Tcl_Interp\s*interp,\sTcl_Obj\s*dictPtr,\r\n\t\t\s\s\s\sconst\schar\s*key,\sTcl_Obj\s**valuePtrPtr);\r\n\tint\tTclDictPut(Tcl_Interp\s*interp,\sTcl_Obj\s*dictPtr,\r\n\t\t\s\s\s\sconst\schar\s*key,\sTcl_Obj\s*valuePtr);\r\n\tint\tTclDictPutString(Tcl_Interp\s*interp,\sTcl_Obj\s*dictPtr,\r\n\t\t\s\s\s\sconst\schar\s*key,\sconst\schar\s*value);\r\n\tint\tTclDictRemove(Tcl_Interp\s*interp,\sTcl_Obj\s*dictPtr,\r\n\t\t\s\s\s\sconst\schar\s*key);\r\n\r\nThe\sfunctions\smake\sthose\soperations\savailable\swithout\shaving\sto\sexplicitly\smake\sa\skey\sobject\s(and\sa\svalue\sobject\sfrom\sa\sclassic\sNUL-terminated\sC\sstring,\sfor\s`TclDictPutString()`)\sand\shandle\sreference\scounts\scorrectly\sso\sthat\sthe\sobjects\sthey\smake\sinternally\swon't\sleak.\s`TclDictPut()`\salso\swill\sdispose\sof\sa\szero-ref\s`valuePtr`\son\serror;\sthe\s`valuePtr`\smust\sbe\sdistinct\sfrom\sthe\s`dictPtr`\s(it\salways\sis\sin\sour\sinternal\suses;\sthe\sreality\sis\sthat\sthe\s`Put`\sfunctions\sare\salmost\salways\sused\swith\sa\s`NULL`\sinterpreter\sand\sa\sdictionary\sthat's\snever\sbeen\sexposed\sto\suser\sscripts).\sIt\smight\sbe\snice\sto\shave\s`TclDictPutInt()`\sor\ssomething\slike\sthat\s—\swe\scould\scertainly\smake\suse\sof\sit!\s—\sbut\sit\sisn't\scritical.\r\n\r\nThey're\scurrently\s`MODULE_SCOPE`\sbut\sbringing\sthem\sout\sto\s`tclInt.decls`\swould\sbe\sacceptable\s(or\sto\s`tcl.decls`\swith\sthe\sobvious\sname\schange;\sa\spublic\sAPI\swould\sneed\sa\sTIP\sbut\sI\swouldn't\ssee\sthat\sas\sa\sproblem,\sas\sI'm\ssure\sI\shave\sthe\sAPI\sreasonably\scorrect).\r\n\r\n##\sRelated\sChanges\r\n\r\nThe\sbranch\sincludes\suses\sof\sthose\sfunctions.\sSometimes\sthis\sresults\sin\squite\sa\sbit\smore\sreadable\scode\s(especially\sin\s`TclDefaultBgErrorHandlerObjCmd()`\sin\stclEvent.c).\r\n\r\nI've\sno\splans\sto\sdo\sa\svarargs\s`TclDictGet`;\sI'm\snot\sconvinced\sthat\swould\sbe\sworth\sit.
J login dkf
J mimetype text/x-markdown
K 656fe3c8163aea1bbf10552962fcc79cb49c5bad
U dkf
Z f618a30016e3266dfc51e60529de2534