Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- From: Ralf Fassel <ralfixx@xxxxxx>
- Date: Wed, 14 Sep 2005 15:21:00 +0200
* Don Porter <dgp@xxxxxxxxxxxxxx>
| Maybe you can find the reason in either TIP 27, or in
| http://wiki.tcl.tk/3669 .
I could not find anything related in TIP 27 itself. On google I found
some earlier discussion which involved char**, paragraph 3 in
http://groups.google.de/group/comp.lang.tcl/browse_thread/thread/a02c34b598c086e4/ba0fd2b3d54f1f10?lnk=st&q=const+argv+group:comp.lang.tcl&rnum=4&hl=de#ba0fd2b3d54f1f10
but I could not find that section in the TIP 27 itself.
However, one reference in http://wiki.tcl.tk/3669 makes me believe
that there is still a misunderstanding on the impact of adding
'const' to char** (or more generally, arrays of pointers) arguments.
http://sourceforge.net/mailarchive/message.php?msg_id=1235712 points
out that
<quote>
I can"t change those to take CONST84 char **s, since then they
wouldn"t be Tcl_CmdProcs anymore. It"s arguable that
typedef int Tcl_CmdProc(
ClientData clientData,
Tcl_Interp *interp,
int argc,
CONST84 char *argv[]);
^^^^^^^
would be the appropriate definition in the Core, since CmdProcs
aren"t supposed to modify the contents of argv[],
</quote>
Note that the above typedef is *NOT* appropriate to achieve a
non-modifiable argv, you need 'CONST84 char *CONST84 argv[]' for that.
And I really think that is what the prototype needs to be, since
exchanging a pointer in the argv-array in the Tcl_CmdProc (which is
possible if the argv itself is non-const) will likely break things
when the Tcl_CmdProc returns and the contents of the argv are for
example free()d.
| If this is really important to you, please file a feature request on
| it. Please include examples of what extension coding will be made
| easier or more elegant by the change.
This would be at sourceforge-TCL?
R'
.
- Follow-Ups:
- Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- From: Joe English
- Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- References:
- Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- From: Ralf Fassel
- Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- From: Don Porter
- Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- Prev by Date: Re: Not a Diff...unique
- Next by Date: Can I wrap the text in a column of a BLT treewidget , when it gets resized interactively.
- Previous by thread: Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- Next by thread: Re: Tip 27: CONST qualifiers on pointer array arguments to TCL functions
- Index(es):
Relevant Pages
|