From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5430b81ad265fc75 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-04-17 13:34:13 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-han1.dfn.de!news-koe1.dfn.de!RRZ.Uni-Koeln.DE!uni-duisburg.de!not-for-mail From: Georg Bauhaus Newsgroups: comp.lang.ada Subject: Re: Array Of Constant Strings? Date: Thu, 17 Apr 2003 20:34:13 +0000 (UTC) Organization: GMUGHDU Message-ID: References: <19guh-2f4.ln1@beastie.ix.netcom.com> <3E4D46B9.6060805@acm.org> <1ec946d1.0304151817.7182ecd8@posting.google.com> NNTP-Posting-Host: d2-hrz.uni-duisburg.de X-Trace: a1-hrz.uni-duisburg.de 1050611653 9271 134.91.1.15 (17 Apr 2003 20:34:13 GMT) X-Complaints-To: usenet@news.uni-duisburg.de NNTP-Posting-Date: Thu, 17 Apr 2003 20:34:13 +0000 (UTC) User-Agent: tin/1.5.8-20010221 ("Blue Water") (UNIX) (HP-UX/B.11.00 (9000/831)) Xref: archiver1.google.com comp.lang.ada:36249 Date: 2003-04-17T20:34:13+00:00 List-Id: Robert A Duff wrote: : Georg Bauhaus writes: : :> Should programming languages have string literals at all? :> I sometimes wonder. : : Heh?! The reason is that I see many situations where a "string literal loading mechanism" is preferable. Here are some: - In many cases programs that do string processing get their strings from outside the program, not from literals in the program text. No string literals here. - String literals are hopelessly scattered throughout programs. (They need not, but they are, for example ad hoc diagnostic messages.) See below. - String literals are rarely typed (other than being a string). That is, string values of the same type are used in very different situations. That is, they defeat explicit abstraction, even though their content might imply the presence of abstraction. (Could be done with wrapper types, but is it done regularly?) - String literals tend to follow their own non-Ada syntax. (Which, again, is not reflected in their type.) - Lots of textual data can be considered data with a structure, but not just a sequence of characters. String literals don't help here. - Often, string literals are in the way of internationalization (That's one reason for the mechanism called "externalising strings" in some IDEs.) (All this doesn't mean I wouldn't be missing string literals for example to quickly add some tracing output.) Some of the strings mentiones must of course come from somewhere, so someone must write them or say them, and some strings must enter program text, for example in exception messages. O.K. So, absent a "string loading mechanism", the strings could at least be named using constants, declared in some packages that group them together according to some predicates like for example, "this is an error message about erroneous input". It is much easier to go from there to internationalisation, than if you had all the strings scattered throughout the program. Consider a message on a display of a teller machine, in Russian, outside Russia. It has been a string literal in the program driving the machine... If there were no string literals, then wouldn't you be forced to just circumvent this deplorable incident? It is so easy, and usual, to (mis)place string literals in program text that people easily forget these issues. This is why I sometimes wonder whether a programming language without string literals is going to be an improvement. Might there not be a causal relation between the presence of string literals in programming languages (bad) and a templates mechanism (Form-Letter Programming) considered a programming pearl (good)?