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!news.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Question on bounded / unbounded strings Date: Sun, 25 Sep 2016 10:50:11 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <11ee98f5-d373-4c72-8562-c310cc76817d@googlegroups.com> <5560c627-b10b-4693-adc0-662776cbdb6c@googlegroups.com> NNTP-Posting-Host: 1YuCPr00zqg9zND3Lb27jw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:31880 Date: 2016-09-25T10:50:11+02:00 List-Id: On 2016-09-24 20:59, John Smith wrote: > On Saturday, September 24, 2016 at 1:45:14 PM UTC-4, Dmitry A. Kazakov wrote: >> Searching for a pattern / skipping irrelevant parts of the input do not >> require that. No need to split anything. > > Then how would you accomplish this? In a loop over the string. There are many algorithms for pattern matching and many pattern languages, e.g. wildcards, regular expressions, SNOBOL/SPITBOL etc. BTW splitting does work anyway if search is not anchored, e.g. you need to find first occurrence of a pattern. >> I would use a stream on top of a segmented buffer, e.g. >> >> http://www.dmitry-kazakov.de/ada/components.htm#Storage_Streams >> >> Or a FIFO if the producer of the content and the SMTP client are run by >> different tasks. >> >> You don't need to build all attachment in the memory in order to be able >> to send it. > > I disagree. If I write out the attachment to disk and then e-mail > it, that's even more overhead. Why do this? Create a neat package in memory, > e-mail it out and then forget about it. Doing this operation in memory > would be easier and faster. And I don't have to worry about temporary > files or any other files (as well as deleting the files, testing this > additional logic, etc.) No, the idea is that the generator of the attachment sends parts of as soon as they are ready. It is a pipeline. The SMTP stack sits on TCP/IP stream that sends chunks away. The stream used as pipeline between the producer and consumer need not to be able to hold all attachment. Its internal FIFO buffer can be limited, the producer is blocked when the buffer is full and consumer is when the buffer is empty. But my point is that Unbounded_String is almost always a poor substitute for more clever and efficient data structures / algorithms. The only excuse to use the former is programmer's laziness. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de