Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.datemas.de!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Rod Pemberton" Newsgroups: comp.lang.forth Subject: Re: FORTH LITE TUTORIAL based on MPE VFX Date: Thu, 26 Jun 2014 17:50:25 -0400 Organization: Aioe.org NNTP Server Lines: 47 Message-ID: References: <2d2eba75-5d44-422a-8a3f-751702d8cea6@googlegroups.com> <5be1ebb2-75e3-433a-bb83-542f3763acb1@googlegroups.com> <45f5f8f9-e2c0-42f1-8640-8108c55d397f@googlegroups.com> <1ad192b0-6c5b-462c-8d19-cad563dbf974@googlegroups.com> <557e2d7a-6003-42af-803b-5d21a00315bd@googlegroups.com> <87ceaa31-134f-4503-8a49-e07b4061b301@googlegroups.com> <29b02601-d43c-4f76-8f3a-02bb4855a09a@googlegroups.com> <31f28699-46bc-4f5b-a1f2-565d663dfd3e@googlegroups.com> <2cb5ef69-0e06-4a07-8594-5f65b3d2a714@googlegroups.com> <4e5d1063-b6f1-4cd8-ae53-be0435e372ee@googlegroups.com> <96e20bcc-9f13-4212-9959-6fa4765b40c1@googlegroups.com> <243713a6-b8b2-4053-bb59-6249ebf6b7f5@googlegroups.com> NNTP-Posting-Host: CNsg4fVcCsvs3UaOgZtQCw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.16 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.forth:31893 On Thu, 26 Jun 2014 04:27:57 -0400, Andrew Haley wrote: > Rod Pemberton wrote: >> Nul-terminated strings eliminated the errors that occur with failure >> to adjust the count on counted strings. > > Zero-terminated strings have two profound disadvantages: they require > scanning in order to determine their length, Most string operations act until a terminator is found, e.g., strcmp(), strcpy(). This is trivially different from decrementing a count and comparing it to zero when copying, comparing, or moving strings, etc. The difference is that no count must be maintained. The string isn't limited by the integer size of a count field. As for a programmer actually needing the length of a string, that's very infrequent. > and they need a sentinel character which is not part of the > character set. So? What computing platform doesn't support both text and binary files? Most platforms support those two and additional others. > The latter is particularly nasty because it requires output functions > to be duplicated: you have to have both fwrite() and fputs(), for > example. Many platforms have multiple file formats that required specialized reads. E.g., the CBM filesystem used in C64 1541 drives etc, which was derived from mainframe platform, supported four: REL, PRG, SEQ, and USR. The Stratus Continuum's supported numerous. I don't recall on the DEC/VAX. > Also, zero-termination means in most cases that substrings can't > share memory. That's not true. It just means you have to either 1) only use one terminator at a time (no 'const'), or 2) use memory copy or compare functions instead of string functions. It means the compiler can't easily setup substrings to share memory. That's different from me inserting and removing terminators for strings. Rod Pemberton