Artifacts Associated With Ticket 784359ffffffffff
Ticket change [ca05849bf7] (rid 122391) by dkf on 2003-08-06 19:32:58:
- assignee initialized to: "msofer"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Yet another idea that cropped up at Tcl'2003: It should be possible to specify a callback for an array that is called whenever an attempt to access (read/write) a non-existant element is made. This would enable all sorts of cool things, according to KBK.
- foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dkf"
- subsystem initialized to: "07. Variables"
- title initialized to: "Tcl'2003: Unknown Array Element Callback"
- type initialized to: "RFE"
Ticket change [e29245a4fe] (rid 87654) by msofer on 2003-08-07 02:51:14:
- icomment:
Logged In: YES user_id=148712 I guess I didn't understand: in what respect is the trace-based solution short of what's requested? Oris it just a matter of performance? % proc readTrace {name1 name2 op} { upvar 1 $name1 ary if {![info exists ary($name2)]} { puts "Non-existent element: set to \"z\"" set ary($name2) z } } % array set a {1 a 2 b} % trace add variable a read readTrace % set a(1) a % set a(2) b % set a(3) Non-existent element: set to "z" z - login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [f639802301] (rid 130262) by msofer on 2004-03-26 23:53:07:
- icomment:
Logged In: YES user_id=148712 dkf: comments?
- login: "msofer"
- mimetype: "text/plain"
- username: "msofer"
- icomment:
Ticket change [567ac1a487] (rid 94323) by dkf on 2004-03-29 16:02:11:
- assignee changed to: "kennykb"
- icomment:
Logged In: YES user_id=79902 Handing this off to kbk; it was his idea originally
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
Ticket change [35a7c5fa36] (rid 106977) by kennykb on 2004-10-31 01:49:27:
- closedate changed to: "2004-10-30T18:49:27"
- closer changed to: "kennykb"
- icomment:
Logged In: YES user_id=99768 Was I sober at the time ? I certainly don't recall why I suggested such a thing, and Miguel's read-trace idea appears workable.
- login: "kennykb"
- mimetype: "text/plain"
- resolution changed to: "Rejected"
- status changed to: "Closed"
- username: "kennykb"
Ticket change [aff630abce] (rid 97906) by msofer on 2004-10-31 02:23:15:
- assignee changed to: "msofer"
- icomment:
Logged In: YES user_id=148712 Reopening - I like it; if it could be done in a manner that doesn't impact performance too much, it could be a VERY good way to define default values for arrays (and also dicts?). Save us a bunch of [info exists], and defining default values for [incr], etc. The idea could be generalised to variables, namespaces, ... Worth thinking about later on.
- login: "msofer"
- mimetype: "text/plain"
- priority changed to: "2"
- resolution changed to: "Postponed"
- status changed to: "Open"
- username: "msofer"
Ticket change [13dbc486d7] (rid 261550) by serhiy.storchaka on 2026-11-13 11:18:45:
- closedate changed to: "2461357.9713335303"
- closer changed to: "serhiy.storchaka"
- icomment:
Default values for missing elements are provided by array default (TIP 508, Tcl 9.0), which also works with incr and lappend. Read traces cover the general callback.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Out of Date"
- status changed to: "Closed"