## Re: [Yaml-core] Reference Problems

 Re: [Yaml-core] Reference Problems From: Clark C . Evans - 2001-11-10 20:37:37 ```Let me explain my vision of References; as motivated by unix file system links. Imagine a reference from a pointer A to a referent X, and a pointer B to a referent X. There are two types of references: a) A indirect ("symbolic") reference, where by altering the referent X to Y through the reference A implies that the referent of B also changes to Y. b) A direct ("hard") reference, where by altering the referent X to Y through the reference A leaves the referent of B pointing to X. Note that a intermediate mutable object plus a direct reference mechanism can be used to construct indirect references. To visualize this, let A and B point to a mutable object M, which points to an object X. When de-referencing A or B, one obtains the value by dereferencing M. Thus, the link from A to X is an indirect or symbolic link (through M). With this thinking... Python natively only supports direct ('hard') references, and not indirect ('symbolic') references. Since an indirect reference can be constructed using a mutable object (a map) and direct references, we can represent indirect references via the mechanism Oren writes below... Brian Ingerson wrote: | \$a = []; | \$a->[0] = \\$a->[1]; | \$a->[1] = \\$a->[2]; | \$a->[2] = \\$a->[0]; Oren Ben-Kiki wrote: | - &000 !reference | =: &001 !reference | =: &002 *000 | - *001 | - *002 Oren is using an intermediate map (!ref) to simulate indirect references. Where the reference map "contains" the item that it refers to. The example above seems to be short one map -- since there are three indirect references, there must be three maps. - &000 !ref =: &001 !ref =: &002 !ref =: *000 - *001 - *002 Brian's approach seems to be using an intermediate list... | - !reflist &001 | - &002 *001 | - &003 *002 | - *003 | - *003 | - *002 In this case, what the reference item refers to is the next item in the list? Clark ```