Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!nrl-cmf!ukma!tut.cis.ohio-state.edu!ucbvax!hplabs!hp-sdd!ncr-sd!rb-dc1!shapiro From: shapiro@rb-dc1.UUCP (Mike Shapiro) Newsgroups: comp.arch Subject: Re: String length Message-ID: <365@rb-dc1.UUCP> Date: 10 Feb 89 00:58:25 GMT References: <1944@lindy.Stanford.EDU> Reply-To: shapiro@rb-dc1.SanDiego.gould.UUCP (Mike Shapiro) Organization: Gould CSD, San Diego Lines: 30 In article <1944@lindy.Stanford.EDU> GQ.RLG@forsythe.stanford.edu (Dick Guertin) writes: <<< deleted reference >>> >Such an implementation has adverse effects when the string is sent >to/from an external device, such as a file. The 'length' must be >with the string, or the string needs a terminator character. >Furthermore, when a 'ptr' is changed to point to a new string, >what happens to the 'length' information for the old string? Note that in Bell Labs language language designed for string handling, SNOBOL4, which appeared in the 1960s (before C, UNIX, et al), string descriptors had three fields for strings in storage: -- pointer to start of string in memory -- offset from start of string storage where string actually starts -- length of string Because the language had many operations on strings, a substring was easy to compute. Copy the string descriptor to the substring descriptor and then adjust the offset and length fields. For more information of string operation implementation, see Ralph Griswold's book on the Macro Implementation of SNOBOL4. Or see his later work on the Icon language. (If desperate for material on how this relates to computer architecture, dig up a copy of my 1972 dissertation on the architecture of a machine for string manipulation -- a SNOBOL machine.) Michael Shapiro