From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!ecngs!feeder2.ecngs.de!news.netcologne.de!ramfeed1.netcologne.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 26 Aug 2010 01:55:51 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.8) Gecko/20100802 Thunderbird/3.1.2 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <4c74cf12$0$6892$9b4e6d93@newsspool2.arcor-online.net> <4c756ccb$0$6771$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4c75ad87$0$6980$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 26 Aug 2010 01:55:51 CEST NNTP-Posting-Host: 6ed7e725.newsspool4.arcor-online.net X-Trace: DXC=`YmFmdR>ino^Y=RbYBPl4`4IUKejVhXb=H:M_cDN`CYP0J`5T[Re X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13746 Date: 2010-08-26T01:55:51+02:00 List-Id: On 8/26/10 12:38 AM, Simon Wright wrote: >> (A B (C D E) F) >> >> '(' ~> push key_1 -- First key will be returned >> >> key_1 : A B key_2 -- '(' ~> push key_2 >> key_2 : C D E -- ')' ~> pop (key_1 on top) >> | >> v >> key_1 : A B key_2 F -- ')' ~> pop (stack empty) >> key_2 : C D E >> >> First_Key := key_1; >> return; > > Oh. I had quite misunderstood your meaning. > > There are issues - like copying a sexp and then deleting or changing > part of one of them, how to know when to delete or duplicate. > > Seems to me that the key is a disguised pointer to a shared structure? key_N is a pointer in disguise, and modifications of key_N entries anywhere need care, recursively. When all Map operations are hidden behind the container operations of package S_Expressions, can copying (in order to prevent structural sharing) still be avoided by implementing copy-on-write? In any case, an optimized version might use a variation of skip lists for Element_Type instead of List, I think. Its pointers point to any key_N is the list, simplifying depth first tree operations (like removing a subtree). Georg