Different string format options, benefits?

Sean C. Cox <coxs2@rpi.edu>
Wed, 16 Oct 91 10:48:54 EDT

          From comp.compilers

Related articles
Different string format options, benefits? coxs2@rpi.edu (Sean C. Cox) (1991-10-16)
Re: Different string format options, benefits? pardo@cs.washington.edu (1991-10-17)
Re: Different string format options, benefits? pk@cs.tut.fi (1991-10-18)
Re: Different string format options, benefits? agulbra@Siri.Unit.NO (1991-10-18)
Re: Different string format options, benefits? db@dcs.ed.ac.uk (Dave Berry) (1991-10-20)
Re: Different string format options, benefits? tm@well.sf.ca.us (1991-10-22)
Re: Different string format options, benefits? buzzard@eng.umd.edu (1991-10-25)
[7 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: Sean C. Cox <coxs2@rpi.edu>
Keywords: code, question
Organization: Compilers Central
Date: Wed, 16 Oct 91 10:48:54 EDT

            I am curious about the benefits/costs related to the two general
character string formats (two I'm familiar with at least). The "C" style
null-terminated, and the (not so standard) Pascal length-string format
(where the length of the string is embedded in the string, usually at the
beginning.


            I can see the advantages of the Pascal-type: fast length determination,
simplification of concatentation (due to the ease of finding the length), etc.
But I'm curious as to the disadvantages, other than the extra overhead to
monitor the length throughout the various operations, and even that can't be
too difficult, since every string will have a known length (for the most part)
at compile time, or during input when the chars will be counted anyhow.


            The C-type strings seem to have the advantage of flexibiility if you
are pretty certain what everything looks like in main memory, and also the
great opportunity to shoot oneself in the foot quite easily.


            Are there any costs/benefits that I seem to be missing here?
[I suspect the real reason is that the PDP-11 had single character move
instructions but no "move N characters." The merits of the two approaches
can, and doubtless will, be argued both ways. -John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.