Re: Pascal vs C style string ?

ddean@robadome.com (Drew Dean)
Mon, 27 Jun 1994 17:54:08 GMT

          From comp.compilers

Related articles
Pascal vs C style string ? guerin@IRO.UMontreal.CA (1994-06-24)
Pascal vs C style string ? ssimmons@convex.com (1994-06-26)
Re: Pascal vs C style string ? prener@watson.ibm.com (1994-06-27)
Re: Pascal vs C style string ? jhallen@world.std.com (1994-06-27)
Re: Pascal vs C style string ? ddean@robadome.com (1994-06-27)
Re: Pascal vs C style string ? boehm@parc.xerox.com (1994-06-27)
Re: Pascal vs C style string ? nandu@cs.clemson.edu (1994-06-27)
Re: Pascal vs C style string ? eifrig@beanworld.cs.jhu.edu (1994-06-28)
Re: Pascal vs C style string ? monnier@di.epfl.ch (Stefan Monnier) (1994-06-28)
Re: Pascal vs C style string ? eru@tele.nokia.fi (Erkki Ruohtula) (1994-06-28)
Re: Pascal vs C style string ? andrew@cee.hw.ac.uk (1994-06-28)
[10 later articles]
| List of all articles for this month |
Newsgroups: comp.compilers
From: ddean@robadome.com (Drew Dean)
Keywords: C, Pascal, design
Organization: ROLM - A Siemens Company
References: 94-06-175 94-06-195
Date: Mon, 27 Jun 1994 17:54:08 GMT

guerin@IRO.UMontreal.CA:
> Is there some reasons to use string0 over length attributed string ??


Steve Simmons <ssimmons@convex.com> wrote:
>Another minor benefit is the restriction on size. String0 has no
>restriction at all other than the user's memory. [...]
>A language purist may find this offensive since implementation of string
>should be independent of the language definition.


There's also one great advantage of giving strings explicit lengths:
0 is no longer a special value. One easy example of this
is if you're printing bitmapped graphics to a dot-matrix printer --
a zero byte means don't fire any pins in this column, not end of string!


More importantly (and this actually bit me) is that some languages,
like Standard ML allow 0 in a string which causes interoperability
problems with a certain OS's RPC system, which assumes strings are
C-style. ML strings are of type string -- there is no length in the
type. They are very useful for dealing with binary data, however, this
usefulness does decrease when C code truncates the string at the first 0
byte.


--
Drew Dean (408) 492-5524
ddean@robadome.com ROLM, a Siemens company
--


Post a followup to this message

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