| Sometimes you want to build a table that is like, but not the same as, another table. You can copy the table element-by-element, but then you have the overhead of the copy (what if you just want to temporarily override a few keys?) and the table copy doesn't get updated if the base table is written to. So yet again I now present a new collection type: the proto-table. To use, just add a table to your call; you can even add keys in the call immediately: (require "lib/proto-table.arc")
(= foo (table 'x 24 'y 25))
(= bar (proto-table foo 'z 26 'x -1))
bar!x
=> -1
bar!y
=> 25
bar!z
=> 26
(= foo!y 1)
bar!y
=> 1
|