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=0.7 required=5.0 tests=BAYES_00,LOTS_OF_MONEY, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e61c8636ef35379d X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-01-13 10:54:06 PST Path: supernews.google.com!sn-xit-03!supernews.com!mtu.ru!newsfeed.sovam.com!newsfeed.cwix.com!news.maxwell.syr.edu!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: Robert Dewar Newsgroups: comp.lang.ada Subject: Re: Escape Sequences in Strings Date: Sat, 13 Jan 2001 18:36:33 GMT Organization: Deja.com Message-ID: <93q77h$rr6$1@nnrp1.deja.com> References: <93objj$guk$1@nnrp1.deja.com> NNTP-Posting-Host: 205.232.38.14 X-Article-Creation-Date: Sat Jan 13 18:36:33 2001 GMT X-Http-User-Agent: Mozilla/4.61 [en] (OS/2; U) X-Http-Proxy: 1.0 x65.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 X-MyDeja-Info: XMYDJUIDrobert_dewar Xref: supernews.google.com comp.lang.ada:3992 Date: 2001-01-13T18:36:33+00:00 List-Id: In article , tmoran@acm.org wrote: > In article > <93objj$guk$1@nnrp1.deja.com>, > robert_dewar@my-deja.com wrote: > > > Ada.Text_IO.Put (Home_Cursor & "hello there!"); You are completely (perhaps deliberately? :-) misreading what I wrote. I was just reacting to your code that embedded a peculiar constant string, and using the above statement to illustrate that if you do want to send strange strings to Put, they should be sent using named constants, that's all! > If I saw this in real code, I would be unhappy. It assumes: > a) that cursor positioning is done by sending a special > string Yes, indeed it assumes that, and that is true at the lowest level in some systems, so at the lowest level, you will see code like this. > b) that this greeting string should always be placed at > cursor home position Sure, that is the assumption in the example, if it is not true of your case, you have to change the example. > c) that the string will always be "hello there!". Sure, that is the assumption in the example, if it is not true of your case, you have to change the example. Note: for my own taste, I hate to present-by-example, and I hate examples, but my experience is most people like examples. For instance, most people want MORE examples in the RM, I regard them as irritating redundant (well hopefully redundant) non-normative junk :-) > A more thorough application of information hiding would > have a low level routine "Home_Cursor" I was of course just showing the kind of code that might appear in low level routines. > used by a mid-level > routine "Move_To_Greeting_Field" which would be followed by > output of a Greeting string from a set of message string > constants. Well such a structure might be appropriate depending on the application. If the program at hand has the following spec, as a homework assignment might: Print "hello there!" at the home position on your screen, then this amount of structure would be overkill. You do sometimes see students doing this kind of thing (making mountains out of molehills :-) But Tom, the real point that I was making is that REGARDLESS of the structure or requirements of your program, NEVER EVER put junk constants in the code, that was the ONLY point I was making, I was not writing a treatise on how to do the abstract top down structure of a program that puts information on the screen. I really think it is bad practice to EVER write even example code that has junk constants in it, as your example did. Yes, it is easy to do when we are being lazy, but it sets a bad example (I certainly have done this in examples in the past, if you go through my own posts, but that does not make it right). I find all the time that people put junk constants in code. MINIMAL (the language which I designed solely for the purpose of writing one program, namely MACRO-SPITBOL) is the only language I know that completely forbids constants except in constant declarations. That's a little fierce, because constants like 1 and 0, and perhaps 2 can reasonably appear in that form, and it is also OK to use constants which are fudnamental to the problem in some cases e.g. 7 for days of the week, but even there naming the 7 as Days_Per_Week can clarify code. Sent via Deja.com http://www.deja.com/