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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.52.109.69 with SMTP id hq5mr33920357vdb.5.1438269196955; Thu, 30 Jul 2015 08:13:16 -0700 (PDT) X-Received: by 10.140.104.147 with SMTP id a19mr640992qgf.2.1438269196935; Thu, 30 Jul 2015 08:13:16 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!z61no4196993qge.0!news-out.google.com!b31ni1442qge.0!nntp.google.com!z61no4196992qge.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 30 Jul 2015 08:13:16 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=81.203.145.32; posting-account=AFCLjAoAAABJAOf_HjgEEEi3ty-lG5m2 NNTP-Posting-Host: 81.203.145.32 References: <2df4698f-4c8e-457c-822d-209cb2f8ab5e@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Running a preprocessor from GPS? From: EGarrulo Injection-Date: Thu, 30 Jul 2015 15:13:16 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: news.eternal-september.org comp.lang.ada:27217 Date: 2015-07-30T08:13:16-07:00 List-Id: On Wednesday, July 29, 2015 at 10:37:48 PM UTC+2, Simon Wright wrote: > "Randy Brukardt" writes: > > > "Simon Wright" wrote in message > > ... > >> I haven't used them often, but don't see the problem with > >> > >> return Tick * Time_Base ((if System.FreeRTOS.Tasks.In_ISR > >> then xTaskGetTickCountFromISR > >> else xTaskGetTickCount)); > > > > Verbosity, for one. Second, the hiding of the control structure. In > > general, it's better to write the control structure out in a > > subprogram body, it's a lot more readable. > > I dunno. The version below is quite verbose, and verges on being less > readable. But this is a style issue, I think. > > if System.FreeRTOS.Tasks.In_ISR then > return Tick * Time_Base (xTaskGetTickCountFromISR); > else > return Tick * Time_Base (xTaskGetTickCount); > end if; KISS solution: TickCount := (if System.FreeRTOS.Tasks.In_ISR then xTaskGetTickCountFromISR else xTaskGetTickCount) return Tick * Time_Base (TickCount); or: if System.FreeRTOS.Tasks.In_ISR then TickCount := xTaskGetTickCountFromISR; else TickCount := xTaskGetTickCount; end if; return Tick * Time_Base (TickCount); :) The above snippets distinguish between the variable expression and the derived expression. I think that the latter form is more readable. By the way, you don't have to wrap the expression in double parentheses (like in the original snippet).