From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Unifont static compiled and stack size... Date: Thu, 17 Aug 2023 22:04:18 -0500 Organization: A noiseless patient Spider Message-ID: References: Injection-Date: Fri, 18 Aug 2023 03:04:00 -0000 (UTC) Injection-Info: dont-email.me; posting-host="e5b47c535e9f0cc2a316ab27ec5e828f"; logging-data="131470"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19galZ1vl0udECVd85yKpTRqBxq3BAWT7M=" Cancel-Lock: sha1:FvCGk6VDdmBUEaIkgApyBCfZNO0= X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-Priority: 3 X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: news.eternal-september.org comp.lang.ada:65532 List-Id: "Dmitry A. Kazakov" wrote in message news:ubhpme$370q7$1@dont-email.me... > On 2023-08-15 10:40, G.B. wrote: >> On 14.08.23 10:31, Dmitry A. Kazakov wrote: >>> >>> P.S. I always wanted static functions in Ada for the purpose of all >>> static initializations of objects like maps etc. >>> >> >> If data form the equivalent of a static Ada array, >> thus a mapping from an index type to a value type, >> could you approximate the static initialization >> of maps using expression functions? > > In general case no. Initialization cannot be decomposed into functions. > E.g. when requires global [yet static] data, many places to set etc. > > P.S. Expression functions are evil. I wonder why there is no expression > gotos and labels? If you sell your soul to the devil, get the whole > package! (:-)) Ada only allows expressions to be evaluated at elaboration time (outside of generic instantations), and expressions have a well-defined and simple control flow (even accounting for conditional expressions and quantified expressions, both of which implicitly appear in aggregates even in Ada 83 -- allowing programmers to write them explicitly makes the code more readable than the horrible work-arounds commonly used pre-Ada 2012). Gotos and labels have arbitrary control flow, which can be much harder to analyze. (Janus/Ada converts the majority of code into an expression form for optimization -- essentially most id statements become if expressions, and so on. It simply punts when the control flow is too complex to convert, so the unrestricted use of gotos effectively prevents most optimization as well as static analysis.) If it was up to me, I would have left out declare expressions and quantified expressions, so the capabilities of expression functions would have been much more limited. But it seems valuable to be able to abstract an expression without changing the semantics (as requiring a separate body does). Randy.