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,c6aaff9993e444f0 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.73.229 with SMTP id o5mr7398889pbv.7.1324544912475; Thu, 22 Dec 2011 01:08:32 -0800 (PST) Path: lh20ni51057pbb.0!nntp.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!news2.euro.net!newsfeed.freenet.ag!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Natasha Kerensikova Newsgroups: comp.lang.ada Subject: Re: String_Holder ? Date: Thu, 22 Dec 2011 09:08:31 +0000 (UTC) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Injection-Date: Thu, 22 Dec 2011 09:08:31 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="7fyd7lCvGVUn5eibBXudkw"; logging-data="5842"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qnshMuc1YV0SQ53AvQ3O6" User-Agent: slrn/0.9.9p1 (FreeBSD) Cancel-Lock: sha1:lVa84xi2Sq0QcwbpdW992Fg5Aa0= Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: 2011-12-22T09:08:31+00:00 List-Id: Hello, On 2011-12-19, Randy Brukardt wrote: > "Natasha Kerensikova" wrote in message > news:slrnjerndj.1lme.lithiumcat@sigil.instinctive.eu... > ... >> Assuming it does make sense, am I right in thinking it's better to have >> such a type, even if it's a thin wrapper around Unbounded_String, >> instead of using directly Unbounded_String? > > What exactly is the advantage of your Holder type over Unbounded_String > (other than shorter operation names :-)? As I answered somewhere else in the thread, having a name in line with the function rather than some irrelevant (in that case) object feature. I would rather have String_Accumulator when I'm building a string by repeated appends, String_Holder when I'm only interested in keeping a reference of it, String_Buffer or String_Queue when I want to append data to be processed by some other subprogram that would retrieve it from head, etc. Even though they can all be implementation with Unbounded_String under the hood, the more specific type allows better self-documentation of the code, and hides Unbounded_String operations that are not natural for the given function (e.g. String_Holder is supposed to reference an immutable string, so any operation that change the underlying Unbounded_String would break stuff). And in case I need extra performance, for whatever measure of performance (be it CPU usage or memory usage or latency consistency or anything else), I can change the implementation of that specific type without affecting any other function. Am I missing something that would be a serious drawback for that way of doing things? > So I don't understand the point -- and you clearly need a reason to write a > new package here rather than using the built-in one. Do I really need a reason? I tend to consider a 20-line specification and a 30-line package body as something extremely cheap. Am I missing something in my cost evaluation? The alternative proposed somewhere else is: type String_Holder is new Unbounded_String; with subprogram renames to remove Unbounded_String-specific parts for better abstraction. I feel it to be about as expensive, except that there is one package for the entire project, while the alternative is per-client-package (unless it gets its own package), so it scales differently. So what am I missing there? Thanks for your insights, Natasha