Check-in [c80f0474ca]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:New TIP 506
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c80f0474ca1fceecc8486c26bb54524c23b42cbecc84a96a1b66fb878cee848c
User & Date: dgp 2018-03-30 17:55:46.349
Context
2018-04-04
09:29
Explain why some TIP #389 proposed changes are upwards compatible. Remove description of Tcl_WinUtfToTChar/Tcl_WinTCharToUtf (implementation-only) change. check-in: 40c11941ea user: jan.nijtmans tags: trunk
2018-03-30
17:55
New TIP 506 check-in: c80f0474ca user: dgp tags: trunk
16:07
Formatting fixes. check-in: 77a2687054 user: dgp tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to index.json.

cannot compute difference between binary files

Changes to index.md.
87
88
89
90
91
92
93







94
95
96
97
98
99
100
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>








<tr class='project projectdraft projectdraft86 project86'>
<td valign='top'><a href='./tip/505.md'>505</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.6.9</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 505: Make [lreplace] Accept All Out-of-Range Index Values</td>
</tr>







>
>
>
>
>
>
>







87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
<th>Title</th>
</tr></thead><tbody>

<tr class='project projectdraft projectdraft90 project90'>
<td valign='top'><a href='./tip/506.md'>506</a></td>
<td valign='top'>Project</td>
<td valign='top'>9.0</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 506: Purge RefCount Macros</td>
</tr>
<tr class='project projectdraft projectdraft86 project86'>
<td valign='top'><a href='./tip/505.md'>505</a></td>
<td valign='top'>Project</td>
<td valign='top'>8.6.9</td>
<td valign='top'>Draft</td>
<td valign='top'># TIP 505: Make [lreplace] Accept All Out-of-Range Index Values</td>
</tr>
Added tip/506.md.




























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# TIP 506: Purge RefCount Macros
	Author:         Don Porter <[email protected]>
	State:          Draft
	Type:           Project
	Vote:           Pending
	Created:        30-Mar-2018
	Post-History:   
	Tcl-Version:	9.0
-----

# Abstract

Stop having all extensions and applications use macros to access the
**refCount** field of the **Tcl_Obj** struct.

# Background

In all of recorded Tcl development history (since version 8.0p2 in 1998),
the "routines" **Tcl_IncrRefCount**, **Tcl_DecrRefCount**, and
**Tcl_IsShared** have been defined as macros, built on top of the
premise that the caller has direct access to the **objPtr->refCount**
field and the **TclFreeProc** routine, which is in public stubs even
though it has a name suggesting a private routine and users of the Tcl
C interface are instructed not to call it other than through the
**Tcl_DecrRefCount** macro.

Like all encapsulation-breaking, the effect is to more strongly
couple together modules of code so that they are inhibited
from freely evolving as independently as they otherwise could.
Simply defining these routines as actual routines would take
away that brittle coupling, and the Tcl 8 -> Tcl 9 transition
is the opportunity to do it.

The disadvantages of the existing implementation are clear, so
why do we have it? I must presume there is at least a strong myth
in place that the macros are necessary to achieve acceptable 
performance. Perhaps that is true. It is a concern to take seriously,
but we should demand evidence. This proposal and its draft implementation
are a chance to consider the actual merit of those claims beyond keeping
up a cargo cult habit.

# Proposal

Remove the macros **Tcl_IncrRefCount**, **Tcl_DecrRefCount**, and
**Tcl_IsShared** from the **tcl.h** file. Create routines in the
public stub table to replace them. Remove **TclFreeObj** from the
public stub table.

# Compatibility

This is a hard binary incompatibility. It is properly proposed
as a change for Tcl 9, where all extensions and applications will
require a re-compile anyway.

# Implementation

On the tip-506 branch.

# Copyright

This document has been placed in the public domain.