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!news3.google.com!proxad.net!feeder1-2.proxad.net!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 27 Aug 2010 16:57:20 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; 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> In-Reply-To: Content-Type: multipart/mixed; boundary="------------080305010206040904020001" Message-ID: <4c77d250$0$7653$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 27 Aug 2010 16:57:20 CEST NNTP-Posting-Host: 1b1ebeb0.newsspool1.arcor-online.net X-Trace: DXC=e;d>`P2UWh9D]ncZ]`hZ;1ic==]BZ:af>4Fo<]lROoR1<`=YMgDjhg2MBHNc?NkSH>nc\616M64>:Lh>_cHTX3j=_RAj0AiRXm= X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:13782 Date: 2010-08-27T16:57:20+02:00 List-Id: This is a multi-part message in MIME format. --------------080305010206040904020001 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit On 27.08.10 15:19, Natasha Kerensikova wrote: > Hello, > > Here is my third attempt, hopefully avoiding the mistakes I did before. Just a few quick comments on style, more or less. The first is to use -gnatwa every now and then, or a similar feature of your Ada compiler or analysis tool. It will tell you which variables are in effect constants, for example. Second, if you assign entire aggregates instead of performing several assignment component by component, this ensures you will never miss a component, should the definition of the type change. Finally, some variables (like First in Iterate_Over_Lists) may or may not serve some purpose, and can be omitted. OTOH, I guess one might want to weigh this against having a meaningful name for a larger construct or consider a more locally declared constant instead (in a declare block). diff attached Georg --------------080305010206040904020001 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="sexp.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="sexp.diff" *** sexp.ada 2010-08-27 15:44:20.000000000 +0200 --- ../sexp.ada 2010-08-27 15:36:52.000000000 +0200 *************** *** 450,454 **** function Root(From : in Container) return Cursor is ! Result : constant Cursor := (Parent => null, Node => From.Root); begin return Result; --- 450,454 ---- function Root(From : in Container) return Cursor is ! Result : Cursor := (Parent => null, Node => From.Root); begin return Result; *************** *** 461,466 **** begin if Position.Node /= null and then Position.Node.Next /= null then ! Result := (Parent => Position.Node, ! Node => Position.Node.Next); end if; return Result; --- 461,466 ---- begin if Position.Node /= null and then Position.Node.Next /= null then ! Result.Parent := Position.Node; ! Result.Node := Position.Node.Next; end if; return Result; *************** *** 473,478 **** if Position.Node /= null then if Position.Node.Next /= null then ! Position := (Parent => Position.Node, ! Node => Position.Parent.Next); else Position := No_Element; --- 473,478 ---- if Position.Node /= null then if Position.Node.Next /= null then ! Position.Parent := Position.Node; ! Position.Node := Position.Parent.Next; else Position := No_Element; *************** *** 570,575 **** raise Constraint_Error with "Position cursor is not a list"; end if; ! Result := (Parent => Position.Node, ! Node => Position.Node.Child); return Result; end Sublist; --- 570,575 ---- raise Constraint_Error with "Position cursor is not a list"; end if; ! Result.Parent := Position.Node; ! Result.Node := Position.Node.Child; return Result; end Sublist; *************** *** 659,664 **** Process_Atom(Current.Atom.all); when List_Node => ! First := (Parent => Current, ! Node => Current.Child); Process_List(First); end case; --- 659,664 ---- Process_Atom(Current.Atom.all); when List_Node => ! First.Parent := Current; ! First.Node := Current.Child; Process_List(First); end case; *************** *** 674,678 **** Process : not null access procedure(Data : in Atom_Data)) is ! Current : constant Node_Access := Start.Node; begin while Current /= null loop --- 674,678 ---- Process : not null access procedure(Data : in Atom_Data)) is ! Current : Node_Access := Start.Node; begin while Current /= null loop *************** *** 689,702 **** Process : not null access procedure(First : in Cursor)) is ! Current : constant Node_Access := Start.Node; ! --First : Cursor; begin while Current /= null loop if Current.Kind = List_Node then ! --First := (Parent => Current, ! -- Node => Current.Child); ! --Process(First); ! Process(First => Cursor'(Parent => Current, ! Node => Current.Child)); end if; end loop; --- 689,700 ---- Process : not null access procedure(First : in Cursor)) is ! Current : Node_Access := Start.Node; ! First : Cursor; begin while Current /= null loop if Current.Kind = List_Node then ! First.Parent := Current; ! First.Node := Current.Child; ! Process(First); end if; end loop; *************** *** 710,714 **** Arguments : in Cursor)) is ! Current : constant Node_Access := Start.Node; Arg : Cursor; begin --- 708,712 ---- Arguments : in Cursor)) is ! Current : Node_Access := Start.Node; Arg : Cursor; begin *************** *** 717,722 **** Execute(To_String(Current.Atom.all), No_Element); elsif Current.Child.Kind = Atom_node then ! Arg := (Parent => Current.Child, ! Node => Current.Child.Next); Execute(To_String(Current.Child.Atom.all), Arg); end if; --- 715,720 ---- Execute(To_String(Current.Atom.all), No_Element); elsif Current.Child.Kind = Atom_node then ! Arg.Parent := Current.Child; ! Arg.Node := Current.Child.Next; Execute(To_String(Current.Child.Atom.all), Arg); end if; --------------080305010206040904020001--