🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.eiffel
Article #1609

Re: class STRING model needs fixing

#1609
From: Badger BA 64810
Date: Fri, 23 Feb 1990 22:11
37 lines
2366 bytes
In article <51017@microsoft.UUCP> alonzo@microsoft.UUCP (Alonzo GARIEPY) writes:
[...]
>I tend to agree that Eiffel is such a lengths-and-indexes language, and that 
>the use of zero-terminated strings isn't buying much performance except to 
>avoid continual conversions when dealing with the operating system.  But 
>conversion can require a very annoying amount of memory management.  The 
>ideal would be a string type that has both a length attribute and zero- 
>termination.  You can keep the length and termination updated all the time 
>or calculate and cache one of them as necessary.  We have been using strings 
>of this kind at Microsoft for years.
[...]
>Alonzo Gariepy				// The opinions expressed above are not
>alonzo@microsoft			// necessarily those of Microsoft Corp.

In a recent issue of ACM SIGPlan notices, a hybrid technique was
described which puts a string length indicator at the end of the
string buffer.  That is, when a fixed-length buffer is allocated, the
*last* byte tells how many bytes to subtract to find the
zero-terminator byte.  By design, this is exactly 0 when the last byte
itself must serve as the zero terminating byte.  

I don't recall if this could be extended to buffers of size > 256.  

Something like buf[last] = number of bytes before buf[last] which 
contain the count.  Might do it:
"ABCDEFGHIJ" =  buf[10] = 0
"ABCDEFGHI." =  buf[10] = 1, buf[9]= 0
"ABCDEFGH.." =  buf[10] = 1, buf[9]= 1, buf[8] = 0

Length of 300 - 259 = 

"0123 ... BCDEFGH.." =  buf[300] = 2, buf[299]= 1(*256), buf[298] = 3
 
----
Bernard A. Badger Jr.	407/984-6385 |"Get a LIFE!" --- J.H. Conway
bbadger@x102c.ess.harris.com         |Buddy, can you paradigm?
bbadger%x102c@trantor.harris-atd.com |'s/./&&/g' Tom sed expansively.
Technical Details
Message-ID: <3253@trantor.harris-atd.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!helios.ee.lbl.gov!nosc!logicon.arpa!trantor.harris-atd.com!x102c!bbadger
References: <48a5572e.12c9a@digital.sps.mot.com> <51017@microsoft.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!hellgate.utah.edu!helios.ee.lbl.gov!nosc!logicon.arpa!trantor.harris-atd.com!x102c!bbadger
From: bbadger@x102c.harris-atd.com (Badger BA 64810)
Newsgroups: comp.lang.eiffel
Subject: Re: class STRING model needs fixing
Message-ID: <3253@trantor.harris-atd.com>
Date: 23 Feb 90 22:11:39 GMT
References: <48a5572e.12c9a@digital.sps.mot.com> <51017@microsoft.UUCP>
Sender: news@trantor.harris-atd.com
Reply-To: bbadger@x102c.ess.harris.com (Badger BA 64810)
Organization: Harris GISD, Melbourne, FL
Lines: 37