Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Annoying ANSI signatures of many Tcl library functions.

Closed219151ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 10 years ago
Descriptionplain2000-10-26 05:02:21
OriginalBugID: 1162 RFE
Version: 8.0.4
SubmitDate: '1999-02-02'
LastModified: '2000-05-17'
Severity: MED
Status: Assigned
Submitter: pat
ChangedBy: hobbs
RelatedBugIDs: 2580
OS: Solaris
OSVersion: 2.6
Machine: Other
FixedDate: '2000-10-25'
ClosedDate: '2000-10-25'


Name:
Krzysztof Kozminski

Extensions:
BLT, DP, Expect, Tree, Itcl, Itk and about a dozen others...

DesiredBehavior:
Many Tcl API procedures take a "char *" argument where they really could take a "const char *" if only some minor effort was dedicated to fixing the procedures that really have no business accessing their arguments as writable strings.

This causes annoying warnings whenever compiling code that follows the discipline of calling constant a constant, e.g., when one uses RogueWave tools for string processing and then tries to pass the result to Tcl.

It would be really nice if functions like:
Tcl_CommandComplete, Tcl_Eval, Tcl_AppendElement, Tcl_StringMatch, Tcl_SetResult, Tcl_FindHashEntry, Tcl_CreateHashEntry, and many others were capable to take const char *.

I tend to consider the current signatures more of a bug, than a missing feature...

KK



Should really use CONST, isn't a big deal, although it changes
many core sigs. (updated stubs and all). 
-- 04/03/2000 hobbs
dgpplain2001-02-08 14:21:26
Kevin Kenny is planning a TIP to tackle this.
kennykbplain2001-04-10 06:17:42
Logged In: YES 
user_id=99768

Of the calls that the user lists, Tcl_Eval and Tcl_SetResult actually need pointers to non-constant strings. 
Tcl_Eval overwrites the string as it is parsing it, and Tcl_SetResult with TCL_DYNAMIC or a user memory 
management procedure requires pointer to non-const so that the memory can be freed.  The other calls 
that the user lists (and many more) can and should be fixed, per TIP#27.
dgpplain2001-04-12 19:39:57
Logged In: YES 
user_id=80530

See also Patch 415648
kennykbplain2002-02-11 03:12:58
Logged In: YES 
user_id=99768

Don, does advancing TIP #27 to Final take care of this?
dgpplain2002-02-11 05:14:50
Logged In: YES 
user_id=80530

Basically, yes.  TIP 27 changed all the interfaces that
can reasonably be changed without major (Tcl 9?) rewrites
to Tcl's internals.

Any script passed to Tcl_Eval and friends must
be a writable string, because parsing of ']' writes on the
string.  Likewise, any variable name must be passed as a
writable string because the parsing of ')' in array element
variables writes on the string.  For these reasons,
Tcl_CommandComplete, Tcl_Eval, etc. have not been changed.
Tcl_SetResult has not been changed because its freeProc
argument controls the real treatment of the string, and
the ability to pass the string to the (freeProc) as a
writable string needs to be preserved.  The following
cast is always safe:

    Tcl_SetResult(interp, (char *) str, TCL_VOLATILE);

and any new code ought to be using Tcl_SetObjResult
anyway.

The other specific requests in this report have all been
converted as part of the TIP 27 effort.

Either close this report entirely, or convert it to a 
Feature Request for the remaining changes to be considered 
in the Tcl 9 time frame.
kennykbplain2002-02-12 02:49:08
Logged In: YES 
user_id=99768

I think Don's comments say it all.
dkf Ticket [219151ffff]: 8 changes [History diff]2016-08-22 12:33:11
Log in (anonymous is fine) to add a comment.