## Re: [Yaml-core] Reference Problems

 Re: [Yaml-core] Reference Problems From: Clark C . Evans - 2001-11-10 22:27:51 ```Suppose we have the following Perl... \$a = 'hello'; \$b = \$a; \$c = \\$a; \$d = [\$a,\$b,\$c]; The YAML representation of \$d would be... - &001 hello - *001 - !pointer to: *001 Where !pointer is a special map type which can have one key "to". Now, this isn't quite cryptic enough for us, so we use !ptr and = instead. - &001 hello - *001 - !ptr =: *001 Note that our new "pointer" type is not the same as our reference (*) type. Best, Clark On Sat, Nov 10, 2001 at 03:49:25PM -0500, Clark C . Evans wrote: | 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 | | _______________________________________________ | Yaml-core mailing list | Yaml-core@... | https://lists.sourceforge.net/lists/listinfo/yaml-core -- Clark C. Evans Axista, Inc. http:\\axista.com 800.926.5525 Collaborative Software for Project Management Patriotisim means protecting core values during difficult times, not pasting a flag on your SUV and repealing the Bill of Rights. ```