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=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: Indentation Date: Fri, 08 Aug 2014 10:16:31 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <0c2b1cf8-125b-44d6-9f46-2dc1c546e5c6@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 8 Aug 2014 17:16:33 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="a0c81a81d1281113b3831cf0c04e791a"; logging-data="12898"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BKdhh2BuZS7vgRTRfUpXcz5NefY72dCk=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: <0c2b1cf8-125b-44d6-9f46-2dc1c546e5c6@googlegroups.com> Cancel-Lock: sha1:DvB5NXObnxQANoZZ+wGCiO263n8= Xref: number.nntp.dca.giganews.com comp.lang.ada:188266 Date: 2014-08-08T10:16:31-07:00 List-Id: On 08/08/2014 09:32 AM, Adam Beneschan wrote: > > An RM example in B.3.3 looks like: > > type T (Flag : Boolean := False) is > record > case Flag is > when False => > F1 : Float := 0.0; > when True => > F2 : Integer := 0; > end case; > end record > with Unchecked_Union; > > That's as good an answer as you're going to get. Other people may have other preferences, but you really can't make an objective case for one or another style as long as it's reasonable. That depends on whether people can agree on a precise specification of why indentation is used. The compiler doesn't care, so it must be for humans, and as it increases writing complexity, it must be for readers. So if we have a precise statement of what indentation is supposed to convey to readers we can speak more objectively about it than just "this is what I like" or "this is what the ARM uses". For me, indentation exists to reflect nesting. If A is indented 1 indentation level from B, then A is nested directly within B; if A is indented 2 levels, then it is nested directly in something else (C) that is nested directly within B. With this definition, the indentation in the ARM example is clearly incorrect. The case statement is nested directly within the type declaration, but is indented 2 levels; F1 and F2 are nested directly within the case statement but are indented another 2 levels. What is new in Ada 12 that I haven't worked with yet is the aspect clause. This is clearly part of the type declaration, not nested within it, and so should be part of the type framing text. So I would probably indent this as type T (Flag : Boolean := False) is record case Flag is when False => F1 : Float := 0.0; when True => F2 : Integer := 0; end case; end record with Unchecked_Union; For a lengthy aspect clause, I like something that indicates clearly that the declaration is not finished yet, so I'd probably use end record with , , ..., ; I've never heard a reason for indentation that resulted in the indentation used by the ARM, or a satisfactory explanation of why the ARM indents record type declarations and case statements the way it does. If one should write type T is record then surely one should also write type T is range type T is array and the like. At the Ada launch (1980 Dec 10), Ichbiah talked about "comb structures" driving the layout of code, and the ARM indentation of records and cases seems to violate that rule. Of course, the ARM indentation goes back to Ada 80, and one can argue that the ARM is never wrong, in which case indentation is arbitrary and the only rule can be "use what the ARM uses". -- Jeff Carter "We call your door-opening request a silly thing." Monty Python & the Holy Grail 17