Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!batcomputer!itsgw!rpi!pawl3.pawl.rpi.edu!jefu From: jefu@pawl.rpi.edu (Jeffrey Putnam) Newsgroups: comp.arch Subject: Re: String lengths Message-ID: <532@rpi.edu> Date: 8 Feb 89 11:17:33 GMT References: <8876@alice.UUCP> Sender: usenet@rpi.edu Followup-To: comp.lang.c Organization: Rensselaer Polytechnic Institute, Troy, NY Lines: 35 In reference to the C representation of strings. Note followups to comp.lang.c. I like the C model for strings. I like it mostly for its simplicity and ease of use. It may well be that a representation for strings that includes string length as a part of a structure is better for efficiency, or more modular or whatever. But! the model used is simple and introduces no magic into the language. Magic? Yup. Magic is what happens when the language (or operating system or hardware) does something odd that is not reachable by the user. This includes magic strings, magic arrays (arrays stored in the same way - that is with extra information hidden from the user), magic library calls (like some VMS calls) and so on. If language (hardware, os) designers want to do something, they should make it evident and available to the user - because if they want to do it, the user probably will as well. In the string question, adding the string length means that what is passed may be a magic cookie that the language knows how to use, but that the user is often denied access to. I have used languages that did lots of magic (the worst was PL/I) and it was often quite difficult to decide what was actually happening (in a function call, for example). The C choice was the simpler one, one with no magic, and the best for the kind of programming that C encourages. Further, if you want to add counted strings, it can be done in C easily. I believe that i have seen a counted string library posted to the net - it might be interesting to see if string handling programs actually run a lot faster with such a library instead of the standard string functions. jeff putnam -- "Sometimes one must attempt the impossible if only to jefu@pawl.rpi.edu -- show it is merely inadvisable."