>>>>> "DS" == Dan Sugalski <[EMAIL PROTECTED]> writes:
>> Correct, especially a list is nothing but a pair with another pair or >> an end-of-list-marker in its second element. To implement set-car! and >> set-cdr! both elements of this pair must be mutable DS> Hmmm. I think we can use one thing for both perl pairs and scheme DS> pairs. We'll need to be careful in spots, though. Perl pairs must DS> have scalars on either side. (Just as arrays and hashes can only hold DS> scalars, not arrays or hashes or lists) but lisp dotted pair actually only can hold scalars in each node too. each node could be a pointer to other stuff or a value. that is classic lisp data structures, all things are trees or lists made from pairs. >> > this implies that pairs >>> should be supported directly in parrot since you can do many >>> optimizations knowing the array has only 2 elements. maybe even support >>> some car/cdr depth variations? i don't see any perl use of cddar but who >>> knows? >> >> Sure. One optimization that comes to my mind, is make the PMC big >> enough to hold 2 PMC-pointers. (actualy it is, if you abuse the >> data-pointer of which I don't know what its good for). My actual patch >> uses the same way PerlArray does with KEY* and KEYPAIR* and the needed >> indirections. DS> The data pointer's for hanging off, well, data from the PMC. Strings, DS> arbitrary chunks of memory, structures to hold arrays and hashes. DS> Y'know, stuff. We could easily make the cache have a PMC in the union. that would be very neat. the actual pmc is the perl key or scheme left node of a dotted pair and the paired PMC (pointer) inside would be the perl value or right scheme node. this makes for easy pair operations for both languages and each paired item can hold anything which is also needed. for lisp/scheme car becomes return the PMC itself and cdr is return the PMC it points to. in perl, key is the PMC itself and value is the PMC it points to. building a list in scheme is easy, the contained PMC just has another PMC in it etc. you get a classic lisp list that way. perl can make a list of pairs with a PMC array type which has key PMC's each of which owns another PMC (the perl value). just to clarify, a PMC would have to have any scalar value AND a pointer to another PMC to be a pair. this shouldn't be a major change but that PMC pointer is not a proper value of the first PMC but its pair. you still need a scalar value in the first PMC for the perl key or the left node value in scheme. so we can't use the data field for the PMC pair pointer as we also need data there for the key or left node. uri -- Uri Guttman ------ [EMAIL PROTECTED] -------- http://www.stemsystems.com -- Stem is an Open Source Network Development Toolkit and Application Suite - ----- Stem and Perl Development, Systems Architecture, Design and Coding ---- Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org