Path: utzoo!mnetor!uunet!mcvax!ukc!eagle!icdoc!doc.ic.ac.uk!cdsm From: cdsm@doc.ic.ac.uk (Chris Moss) Newsgroups: comp.lang.prolog Subject: re: Strings Message-ID: <241@gould.doc.ic.ac.uk> Date: 24 Mar 88 18:35:05 GMT Sender: news@doc.ic.ac.uk Reply-To: cdsm@doc.ic.ac.uk (Chris Moss) Organization: Dept. of Computing, Imperial College, London, UK. Lines: 78 I haven't contributed to the string discussion because I don't believe I know all the answers. But I do have strong reservations about the current Edinburgh implementations. Let me air them: 1. They don't get printed properly by "write". I don't like seeing "Prolog" come out as [80,114,111,108,111,103]. OK, I can define a "writestring", but not use it within a bigger structure without pain. Now here's an odd thing: there is no writestring routine in the Quintus library that I can discover! Not in the built-ins or the (extensive) library! What does that tell us about the use of strings? It suggests to me that people actually always use atoms for this purpose, and somewhere in their code is an implicit definition: writestring(String) :- name(Atom,String),write(Atom). Note that in most systems this involves an entry in the symbol table (reasonably slow) and a limit of 256 (or maybe 512) characters. MuProlog DOES print out "Prolog" as a string, wherever it occurs. Presumably it has to scan the list first. It uses list format whenever there is a integer outside the range 32-127 in the list (it also gets tabs right tho I don't understand why it finishes at 127 not 126). That's a pretty good heuristic, tho I can imagine it going wrong on occasions. e.g. if I read in a clause over several lines the string will contain newlines, so my DCG debugging will still look horrid! 2. I don't like having ASCII values in my programs. With a certain amount of discipline and inefficiency one can get round that, by saying, for instance: lowercase(X) :- "a"=[A], "z"=[Z], X>=A, X=