From: Clark C . E. <cc...@cl...> - 2001-11-11 04:54:44
|
On Sat, Nov 10, 2001 at 07:55:14PM -0800, Brian Ingerson wrote: | Perl does not need two different kinds of references. Ok. I'm not a perl head, so take it easy on me. $a = [0] $b = $a $c = \$a How do $b and $c differ? $b->[0] = 9 print $a->[0] Prints out "9". So, somehow, someway, $b is an alias for the array also pointed to by $a. This is the *alias* mechanism, and Perl seems to have it. This is what &001 and *001 were design to encode. The first time an object is encountered it is serized and given an anchor, then on subsequent appearences, we use *001. Right? Let's call this an "alias". And an "alias" is not what I have with $c above... no? Thus, we need another mechanism. An explicit map having the type !ptr works just great. As it says on P245 of camel book at the bottom: "[the \ mechanism] works much like the & operator in C". Thus, I'm calling the "reference" in Perl a pointer. Java and Python don't have pointers... Perl does. That's all. Right? So we need a pointer mechanism (or type). But I don't think that pointers need be at all related to our alias mechanism. The map syntax that Oren started and I tried to explain will allow round-tripping pointers through any YAML system without pointers... as it is stored as a map with a particular type. Kinda cool, if you ask me. Clark |