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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ac4955b8006bd13c X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.220.230 with SMTP id pz6mr1274592pbc.3.1338450772421; Thu, 31 May 2012 00:52:52 -0700 (PDT) Path: l9ni2927pbj.0!nntp.google.com!news1.google.com!postnews.google.com!w24g2000vby.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: Q: type ... is new String Date: Thu, 31 May 2012 00:37:22 -0700 (PDT) Organization: http://groups.google.com Message-ID: <336f4e4b-16da-4fa8-9b7a-7e2dd3a48018@w24g2000vby.googlegroups.com> References: NNTP-Posting-Host: 195.182.34.254 Mime-Version: 1.0 X-Trace: posting.google.com 1338450772 31233 127.0.0.1 (31 May 2012 07:52:52 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 31 May 2012 07:52:52 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: w24g2000vby.googlegroups.com; posting-host=195.182.34.254; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; Linux x86_64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1,gzip(gfe) Content-Type: text/plain; charset=ISO-8859-1 Date: 2012-05-31T00:37:22-07:00 List-Id: On 30 Maj, 18:33, tmo...@acm.org wrote: > Any comments on the effectiveness of using multiple types for different > categories of strings, rather than "String" all the time? Interestingly, this is a bit different from defining multiple number types instead of using standard types all the time. The difference is that number types carry bounds as additional information and that can be comfortably used to later define arrays, loop ranges, etc. Strings don't have this capability (unless, of course, you define constrained String (A .. B) types) and the only added value of defining separate types is in (potentially) increased readability and (potential) compile-time assistance in avoiding mixing apples with oranges. I write "potentially" in braces, as the balance between costs and gains is not always obvious here - in particular, a gain in readability can be devastated by later need to instantiate tons of generics or spraying type casts all over the shop just to get simple things done (example: try to print a log message containing several of such values). It is a typical engineering tradeoff between being rock-solid and lightweight. As to performance (if that was your original question), you *can* expect some performance degradation due to these tons of instantiated generics increasing the executable working set and competing for cache space. How much? I have no idea. :-) And it has to be judged in the context of the target system. -- Maciej Sobczak * http://www.msobczak.com * http://www.inspirel.com