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: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Running a preprocessor from GPS? Date: Thu, 30 Jul 2015 13:16:46 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <2df4698f-4c8e-457c-822d-209cb2f8ab5e@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1438280208 25037 24.196.82.226 (30 Jul 2015 18:16:48 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 30 Jul 2015 18:16:48 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: news.eternal-september.org comp.lang.ada:27230 Date: 2015-07-30T13:16:46-05:00 List-Id: "Jeffrey R. Carter" wrote in message news:mpbbq4$nkm$1@dont-email.me... ... > One of the few arguments I've heard for conditional expressions that might > make > sense is that > > X := (if Y then 2 else 0); > > makes it clear that the purpose of the "if" is to choose the value of X, > while in Yes, I suppose that's true. (It doesn't come up that often in practice, as usually there is something else in one of the branches, like a trace or a second assignment.) The main reason I suggest using them is if the expression needs to be static: X : constant Integer := (if Y then 2 else 0); If Y is static, then this expression will be static. In previous versions of Ada, one had to use tricky expressions involving multiplying by the Boolean'Pos to get a static expression, at huge readability cost. And, of course, if an expression is required for other reasons (Preconditions, Predicates, expression functions), then you have no choice. Introducing a function (and coming up with a meaningful name for it!!) is a pain and does not necessarily help the readability of these things (and it definitely reduces the possibilities for proof/optimization at compile-time [as opposed to in a separate, whole program tool like SPARK]). Randy.