Core: Value references docs

git-svn-id: svn://ultimatepp.org/upp/trunk@7680 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2014-09-13 14:23:12 +00:00
commit 82ee6afcc8
7 changed files with 184 additions and 4 deletions

View file

@ -0,0 +1,45 @@
topic "Rules for references to Value internal maps elements";
[2 $$0,0#00000000000000000000000000000000:Default]
[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class]
[l288;2 $$2,2#27521748481378242620020725143825:desc]
[0 $$3,0#96390100711032703541132217272105:end]
[H6;0 $$4,0#05600065144404261032431302351956:begin]
[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item]
[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement]
[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param]
[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam]
[b42;2 $$9,9#13035079074754324216151401829390:normal]
[a83;*R6 $$10,12#31310162474203024125188417583966:caption]
[b83;*2 $$11,12#07864147445237544204411237157677:title]
[b42;a42;2 $$12,12#45413000475342174754091244180557:text]
[{_}%EN-US
[s10; Rules for references to Value internal maps elements&]
[s0; Value is originally designed as nonmutable concrete Value of
different concrete types.&]
[s0; &]
[s0; However, as Value is commonly used to store complex hierarchies
(using ValueArray/ValueMap types), it is in the end very useful
to be able to reference ValueArray/ValueMap elements directly.
Validity of such references is restricted by following rule:&]
[s0; &]
[s0; Reference obtained from Value (by Value`::At, Value`::GetAdd,
ValueArray`::At, ValueMap`::GetAdd and derivative methods) are
[* only valid until the next operation on originating Value `-
including just reading it.]&]
[s0; &]
[s0; Examples of invalid code:&]
[s0; &]
[s0; [*C@5 Value m;]&]
[s0; [*C@5 Value`& x `= m(`"key`");]&]
[s0; [*C@5 x `= m; // using m as source invalidates x]&]
[s0;*C@5 &]
[s0; [*C@5 Value m;]&]
[s0; [*C@5 Value`& x `= m(`"key`");]&]
[s0; [*C@5 Value`& y `= m(`"key2`"); // Invalidates x]&]
[s0; [*C@5 x `= 123; // undefined]&]
[s0;*C@5 &]
[s0; [*C@5 Value m;]&]
[s0; [*C@5 Value`& x `= m.At(1);]&]
[s0; [*C@5 Value m2 `= m; // Invalidates x]&]
[s0; [*C@5 x `= `"fail`"; // undefined]&]
[s0; ]]