macro for sentinels
Recent check-in [c6d3960498] included a large number of changes where a sentinel argument was changed from (void) NULL to (char *) NULL Would we get code maintenance benefit from a macro in a header file: #define TCL_SENTINEL (char *) NULL so we can make any similar future modifications in one place?
Actually, it was changed from (void *)NULL to (char *)NULL. The reason for this is just readability: It is used in functions like Tcl_SetErrorCode(), Tcl_AppendResult(), and Tcl_AppendStringsToObj(), which expect strings in all its elements. Using (char *)NULL makes it immediately clear that the last sentinel argument is a string too.
Using TCL_SENTINEL would hide that information, I don't think we want that. In functions like mp_init_multi() sentinels are used as well, but there the arguments are not strings. Therefore (void *)NULL is kept there: It could have been changed to (mp_int *)NULL, but that looks more ugly.
Just my 2c
Can't resist to throw my 2 cents into this debate. Few months ago we had a similar discussion about the cons and pros of TCL_UNUSED and my argument against it was information loss. Now, the use of TCL_SENTINEL is information loss, too, and arguably not favorable? Am I the only one who's somewhat puzzled?
lol. So you would prefer `TCL_SENTINEL(char *)` then ??
The difference with TCL_UNUSED is that C/C++ already has the standard construct `(type)NULL` for exactly what we want here.
That 2 more cents, making 6 ;-)
Lemme be clear, neither do I like TCL_UNUSED, nor TCL_SENTINEL. Both hide in my irrelevant opinion information. But if that is culturally common sense, so be it and I need to get used to it and finally have to live with it.
Is it really necessary to switch cast from (char *)NULL to (void *)NULL?
I mean isn't void * compatible with (char *)NULL? And from point of view the functions with variadic args like Tcl_AppendResult it is also the same thing.
So let it be (char *)NULL everywhere - no changes across versions, no conflicts, no special sentinel macro needed...
> So let it be (char *)NULL everywhere - no changes across versions, no conflicts, no special sentinel macro needed...
Yes, that's the idea....
Closing: the consensus above was to keep the explicit (char *)NULL sentinels.