Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!rochester!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!ForthNet From: ForthNet@willett.pgh.pa.us (ForthNet articles from GEnie) Newsgroups: comp.lang.forth Subject: PUZZLES AND PROBLEMS Message-ID: <1510.UUL1.3#5129@willett.pgh.pa.us> Date: 13 Aug 90 03:45:13 GMT Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 96 Category 3, Topic 35 Message 130 Sun Aug 12, 1990 W.BADEN1 [Wil] at 09:35 PDT congratulations to mitch bradley on being the first person to offer what i agree is readable forth code if everyone wrote code the way mitch has shown then forth would not have the reputation of being "write only" any improvement i can make will be marginal and moot others have uploaded further examples of readable forth and i will comment on them later mitch has recognized the obvious fact about forth readability you can't understand what the code does if you don't know what's on the stack the obvious way to handle this is: make sure there's never any question as to what's on the stack mitch has done this as well as telling in plain english what the intent of the code is i hope that if you have read this far you can see another way in which readability can be improved the distinction between upper and lower case was introduced to make writing more readable all lower case is easier to read than all upper case but mixed upper and lower is still better most languages also use punctuation marks to improve readability let's rewrite the beginning of this as it should be done in plain english Congratulations to Mitch Bradley on being the first person to offer what I agree is readable Forth code. If everyone wrote code the way Mitch has shown then Forth would not have the reputation of being "write only". Any improvement I can make will be marginal and moot. Others have uploaded further examples of readable Forth and I will comment on them later. Mitch has recognized the obvious fact about Forth readability. You can't understand what the code does if you don't know what's on the stack. The obvious way to handle this is: Make sure there's never any question as to what's on the stack. Mitch has done this as well as telling in English what the intent of the code is. It is curious that Forth programmers are typically Proud To Be Different and deprecate C, yet many blindly imitate old-fashioned C style. Contemporary C programming is groping toward a significant use of mixed upper and lower case. C programming can be more tolerant of monocase because it has punctuation marks to clarify syntax (parens, commas, brackets, semicolons). Modern languages of Western civilization using a Latin, Greek, or Cyrillic alphabet normally begin complete thoughts with an upper case letter, and terminate them with a full stop, question mark, or exclamation mark. Forth does not have punctuation marks and uses extra spacing and subordination instead. A convention that I believe makes for more readable code is: ALL UPPER CASE for standard and would-be standard words. First Letter Upper Case for new words not expecting anything on the stack. first letter lower case for new words expecting something on the stack. \ Comments in proper English syntax with final punctuation. Extra spacing shows stack state is the same as previously indicated. If the stack state at extra spaces for phrasing is different from the previously indicated state there should be a stack comment. This results in complete thoughts beginning with upper case, and modifying phrases separated by extra spacing. Some other convention may work as well, but if Forth code is to be readable with adequate comments the present trend to all lower case must be cured. In an application the names of new words should all be distinct ignoring case. E.g., don't define "glean" and "Glean". Mitch's examples are very readable and my improvement is minuscule. Nonetheless there was room for improvement. Some readers may recall my 1970 "Principle of Mutual Superiority." Anything you do I can do better. Anything I do you can do better. Anything I do I can do better. Anything IBM does will cost more money. The last was revised in 1989 to Anything IBM or Apple does will cost more money. Procedamus in pace. ----- This message came from GEnie via willett through a semi-automated process. Report problems to: uunet!willett!dwp or dwp@willett.pgh.pa.us