Check-in [eb537ee186]

Login

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

Overview
Comment:Update TIP with experience of implementing it
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: eb537ee186e7e0332b07f83e17bb03c86de20c9547514c6d9d0a1a2d51c2499e
User & Date: dkf 2019-06-15 07:48:01.388
Context
2019-06-15
17:25
Five TIPs all Accepted check-in: 2a211da819 user: dkf tags: trunk
07:48
Update TIP with experience of implementing it check-in: eb537ee186 user: dkf tags: trunk
2019-06-14
14:45
Formatting check-in: b2f25446c3 user: jan.nijtmans tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/450.md.
1
2

3
4
5
6
7
8
9
# TIP 450: Add [binary] subcommand "set" for in-place modification
	Author:         Arjen Markus <[email protected]>

	State:          Draft
	Type:           Project
	Vote:           Pending
	Created:        18-Jul-2016
	Post-History: 
	Tcl-Version:    8.7
	Keywords:       Tcl, binary data


>







1
2
3
4
5
6
7
8
9
10
# TIP 450: Add [binary] subcommand "set" for in-place modification
	Author:         Arjen Markus <[email protected]>
	Author:         Donal K. Fellows <[email protected]>
	State:          Draft
	Type:           Project
	Vote:           Pending
	Created:        18-Jul-2016
	Post-History: 
	Tcl-Version:    8.7
	Keywords:       Tcl, binary data
47
48
49
50
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82

83
84
85
86
87
88
89
90
91
92
93
94

The new command will have the effect that the first few steps are not
necessary anymore.

# Implementation Notes

Besides the nominal case of a variable that contains a binary array that is to
be updated within the bounds of that array, three other cases exist and need
to be prepared for:

 * The variable _varName_ does not exist yet


 * The variable _varName_ does not contain a binary array

 * The updating would go past the memory allocated for the binary array

Each of these cases and perhaps others will have to be taken care of. The
first case might be treated as if **binary format** was meant. For the
second case the implementation can convert the current value.

The third case might either cause an error \(we are updating an existing block
of memory after all\) or silently extend the memory, effectively performing
what the Tcl implementation shown above would do. If an error is thrown, then
the first case should probably throw an error as well.

# Reference Implementation

To be committed to a fossil branch.

A few remarks:

 * The third case is not completely treated yet \(see "TODO" in the code\)

 * The **binary set** command does not properly invalidate the string
   representation. The binary array is, however, updated properly - at least
   according to the very limited tests that were performed.


 * There are no proper test cases yet.

 * There is no proper performance measurement yet; this could be based
   on Wiki page <http://wiki.tcl.tk/44363.>

 * It does not deal with the possibility that the binary array is shared.

# Copyright

This document is placed in public domain.








|


|
>

|
|
<

|
|
<
|
<
<
<
<

<
|
<
|
<
|
<
|
|
<
<
>

|

<
<
|
<




<
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

63
64
65

66




67

68

69

70

71
72


73
74
75
76


77

78
79
80
81


The new command will have the effect that the first few steps are not
necessary anymore.

# Implementation Notes

Besides the nominal case of a variable that contains a binary array that is to
be updated within the bounds of that array, four other cases exist and need
to be prepared for:

 * The variable _varName_ does not exist yet: we must create the
   variable when writing back the binary value.

 * The variable _varName_ does not contain a binary string: we must
   convert the variable to a binary string (using the usual algorithm).


 * The variable _varName_ contains a binary string that is shared with
   other uses (such as being stored in other variables): we must

   duplicate the binary string in this case before updating it.






 * The updating would go past the memory allocated for the binary

   array: we must extend the binary array.

   

_It is the Tcl programmer's responsibility to avoid these cases if they
matter to them._ The **binary set** command will act in accordance


with existing Tcl standard semantics.

# Reference Implementation



See the `tip-450` branch.


# Copyright

This document is placed in public domain.