From: John Smith <yoursurrogategod@gmail.com>
Subject: Re: Question on bounded / unbounded strings
Date: Sat, 24 Sep 2016 11:59:58 -0700 (PDT)
Date: 2016-09-24T11:59:58-07:00 [thread overview]
Message-ID: <5560c627-b10b-4693-adc0-662776cbdb6c@googlegroups.com> (raw)
In-Reply-To: <ns6e2u$1nu7$1@gioia.aioe.org>
On Saturday, September 24, 2016 at 1:45:14 PM UTC-4, Dmitry A. Kazakov wrote:
> >>> If you need to separate a large string into a bunch smaller ones
> >>> that do not have a pre-determined size, using a fixed string does not make
> >>> any sense.
> >>
> >> I *never* need that. It was discussed already.
> >
> > If a file is read in (the format is non-standard) and you now need
> > to sift through the details of the file, you will need this.
>
> 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?
> >>> When you do need to build a string, it is far easier to have one
> >>> unbounded string that is added on to and then written out.
> >>
> >> No, it is easier with fixed strings.
> >
> > How?
> >
> > I've tried going to the example on your website, but it seems that that is down.
>
> Hmm, it is not down:
>
> http://www.dmitry-kazakov.de/ada/strings_edit.htm
> http://www.dmitry-kazakov.de/ada/components.htm#Parsers_etc
>
I'll have a look when I get home.
> >>> Having a
> >>> fixed string means that I woul need something along the lines of a
> >>> recursive solution, since I can't extent the size of the string after
> >>> it's been instantiated.
> >>
> >> The output length for formatted output is always known. Normally the
> >> parts of a composite string are statically known, that precludes
> >> iteration or recursion. In other cases, like building a directory path
> >> from some structure, I first calculate the length and then declare the
> >> result string.
> >
> > No, it is almost always unknown in my experience :-). If I'm putting
> > together a report that needs to be e-mailed out, I have no idea how long
> > it will be. I would first need to do my thing, get the string returned
> > from it, append it to an accumulator string and after all of that was
> > done, I can now know its length.
>
> But a mail body is not a string! If you send a MIME attachment the
> natural way to do it is to use a stream as the source. String can be
> used, but for short text mails only.
>
> I believe AWS takes streams for attachment. My implementation of SMTP
> certainly does:
>
> http://www.dmitry-kazakov.de/ada/components.htm#GNAT.Sockets.SMTP.Client.Attach_Stream
>
Sure it is. This is especially true when it comes to sending out a string e-mail (and a bunch of HTML can be put on a single line.) But the e-mail example is just one that I could think of on a dime.
I'll have a look at what you did when I get home.
> > If I were to first run my analysis, get the length of the string
> > (which is the result that will go out), then keep doing this until I'm
> > finished (at which point I will be able to figure out how big my
> > accumulator is supposed to be.) Now, I would have to re-run my analysis
> > again and then copy in the results into the my newly allocated
> > accumulator string. That would make for some needlessly complex logic in
> > my application (as opposed to just dump everything to an unbounded string.)
>
> 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.)
> > However, if I ever need string functionality that I'm used to in
> > Python or C++, Unbounded strings are the only reasonable solution.
>
> You used to use dynamic strings. But there is no evidence they really
> simpler to use. In my code which varies from network protocols to
> compiler developing tools and AI you will find almost no
> Unbounded_Strings. Would it be simpler with Unbounded_Strings? I doubt it.
>
When I get home, I'll have a look at what you've written.
next prev parent reply other threads:[~2016-09-24 18:59 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 8:46 Question on bounded / unbounded strings Arie van Wingerden
2016-09-13 9:04 ` Dmitry A. Kazakov
2016-09-22 2:10 ` John Smith
2016-09-22 7:24 ` Dmitry A. Kazakov
2016-09-22 9:01 ` J-P. Rosen
2016-09-22 9:53 ` Dmitry A. Kazakov
2016-09-22 10:58 ` G.B.
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 14:14 ` G.B.
2016-09-22 17:18 ` Dmitry A. Kazakov
2016-09-22 11:08 ` J-P. Rosen
2016-09-22 12:05 ` Dmitry A. Kazakov
2016-09-22 13:18 ` Maciej Sobczak
2016-09-22 13:52 ` Dmitry A. Kazakov
2016-09-22 14:51 ` Maciej Sobczak
2016-09-22 17:13 ` Dmitry A. Kazakov
2016-09-23 5:50 ` Maciej Sobczak
2016-09-23 6:36 ` Simon Wright
2016-09-23 7:48 ` Dmitry A. Kazakov
2016-09-28 20:55 ` Randy Brukardt
2016-09-23 23:58 ` John Smith
2016-09-24 7:52 ` Dmitry A. Kazakov
2016-09-24 16:25 ` John Smith
2016-09-24 17:44 ` Dmitry A. Kazakov
2016-09-24 18:33 ` John Smith
2016-09-24 18:37 ` John Smith
2016-09-24 18:59 ` John Smith [this message]
2016-09-25 8:50 ` Dmitry A. Kazakov
2016-09-25 23:35 ` brbarkstrom
2016-09-26 7:28 ` Dmitry A. Kazakov
2016-09-26 12:39 ` brbarkstrom
2016-09-28 21:09 ` Randy Brukardt
2016-09-30 7:59 ` Björn Lundin
2016-09-13 9:35 ` gautier_niouzes
2016-09-13 10:41 ` Alejandro R. Mosteo
2016-09-13 17:41 ` Jeffrey R. Carter
2016-09-13 17:59 ` Björn Lundin
2016-09-14 11:23 ` Arie van Wingerden
2016-09-14 12:26 ` Arie van Wingerden
2016-09-14 12:28 ` Arie van Wingerden
2016-09-14 12:57 ` Arie van Wingerden
2016-09-14 19:39 ` Jeffrey R. Carter
2016-09-17 16:35 ` Arie van Wingerden
2016-09-16 14:43 ` Olivier Henley
2016-09-17 16:35 ` Arie van Wingerden
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox