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: a07f3367d7,86b57370403509bc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!news.k-dsl.de!news.tornevall.net!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Disabling string evaluation in a logging system Date: Tue, 18 May 2010 11:17:16 -0700 Organization: TornevallNET - http://news.tornevall.net Message-ID: References: NNTP-Posting-Host: ae328783eab4c3fe8db1cb729eabe3a5 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: df0396a47785e99943a96458c2271728 X-Complaints-To: abuse@tornevall.net User-Agent: Thunderbird 2.0.0.24 (X11/20100411) X-Complaints-Language: Spoken language is english or swedish - NOT ITALIAN, FRENCH, GERMAN OR ANY OTHER LANGUAGE! In-Reply-To: X-Validate-Post: http://news.tornevall.net/validate.php?trace=df0396a47785e99943a96458c2271728 X-SpeedUI: 1738 X-Complaints-Italiano: Non abbiamo padronanza della lingua italiana - se mandate una email scrivete solo in Inglese, grazie X-Posting-User: 0243687135df8c4b260dd4a9a93c79bd Xref: g2news2.google.com comp.lang.ada:11738 Date: 2010-05-18T11:17:16-07:00 List-Id: stefan-lucks@see-the.signature wrote: > > package Flexi_Log is > > procedure Write(Log_Level: Log.Level_Type; > Message_1: String := ""; > Message_2: String := ""; > Message_3: String := ""; > ... > Message_9: String := ""); > -- if Log_Level>0 then > -- Log.Write(Message_1 & Message_2 & ... , Log_Level); > -- end if; > > end Flexi_Log; > > In any case, the number of different strings to make one message is > constant. The constant is under your control, but it is constant. If your > support goes for up to, say, Message_9, a message for the log which > consists of 10 or more parts may still trouble you. So change the constant > sufficiently large that it doesn't trouble you too often ... You could also do something like: type Message_List is array (Positive range <>) of Ada.Strings.Unbounded; procedure Write (Level : Log.Level_ID; Message : Message_List); -- If Level > No_Logging and Message'Length > 0 then log the concatenation of -- the strings in Message. But I don't see that it buys you much, if anything. Ultimately, this sounds like a case of premature optimization, given that the string operations are not impacting your timing requirements, according to another post. -- Jeff Carter "You've got the brain of a four-year-old boy, and I bet he was glad to get rid of it." Horse Feathers 47