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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4f316de357ae35e9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-08-04 20:46:02 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!news-west.rr.com!cyclone.kc.rr.com!news.kc.rr.com!cyclone3.kc.rr.com!news3.kc.rr.com!twister.socal.rr.com.POSTED!not-for-mail Message-ID: <3D4DF503.85EA4594@san.rr.com> From: Darren New X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: FAQ and string functions References: <20020730093206.A8550@videoproject.kiev.ua> <4519e058.0208010629.5e6182ca@posting.google.com> <20020801194720.Q1080@videoproject.kiev.ua> <4519e058.0208020605.5ab7e092@posting.google.com> <3D4AAF63.72782659@san.rr.com> <3D4B2382.7030209@telepath.com> <3D4B2ACD.FDA29B9A@san.rr.com> <3D4B401E.3060802@telepath.com> <3D4B4477.500088B@san.rr.com> <3D4BCEC9.9030108@telepath.com> <3D4C0ABA.F38204E3@san.rr.com> <3D4C7DE5.9060408@telepath.com> <3D4D551F.190A19C0@san.rr.com> <5ee5b646.0208041816.13c1b3bb@posting.google.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Mon, 05 Aug 2002 03:45:47 GMT NNTP-Posting-Host: 66.74.216.166 X-Complaints-To: abuse@rr.com X-Trace: twister.socal.rr.com 1028519147 66.74.216.166 (Sun, 04 Aug 2002 20:45:47 PDT) NNTP-Posting-Date: Sun, 04 Aug 2002 20:45:47 PDT Organization: RoadRunner - West Xref: archiver1.google.com comp.lang.ada:27687 Date: 2002-08-05T03:45:47+00:00 List-Id: Robert Dewar wrote: > That's all a loop is, syntactic sugar for tail > recursion. This is only true if it's actually tail recursion. However, ensuring you have only tail recursion can be difficult in a procedural language like Ada. If I have a local variable that is controlled, or an in-out variable of the procedure, or the array or its components are controlled, I don't think Ada can safely eliminate the tail recursion. So if, for example, it's an array of unbounded_string as implemented in GNAT, I expect the compiler would have a hard time eliminating the tail recursion, would it not? I'm not sure I'd want to write algorithms that only work right when the compiler eliminates tail recursion, also, since the compiler doing that isn't specified in the ARM, is it? Or am I wrong on that? > > I.e., if you have something > > > > that's difficult to program in a functional style. > > None of the examples you give are even vaguely in this > category (unless you have difficulty programming in a functional > style, No, simple problems that can't be done recursively are difficult to find. Difficult problems that can't easily be done recursively are difficult to post to a newsgroup. > Well then unless you intend to emulate Humpty-Dumpty in > Alice, please use technical defintions the same way as > the rest of the world. http://www.netlingo.com/lookup.cfm?term=parse "Parsing is often divided into lexical analysis and semantic parsing..." > > For example, implement the Ada.Strings.Unbounded package > > using only recursion to allocate record sizes. > Of course it's possible, and easy if you have a reasonable > familiarity with writing in a recursive style. Can you show me how to implement procedure Ada.String.Unbounded.Append(source:in out Unbounded_String; New_Item : in Unbounded_String) using recursion? That is, how would you write this if Unbounded_String didn't use an access value? How about procedure insert(source:in out unbounded_string; before : in Positive; new_item : in String)? Seriously, I'd like to see how it's done in Ada. -- Darren New San Diego, CA, USA (PST). Cryptokeys on demand. ** http://images.fbrtech.com/dnew/ ** They looked up at me like I was a T-bone steak walking into an all-you-can-eat seafood buffet.