comp.lang.ada
 help / color / mirror / Atom feed
* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-05 21:00 Bill Yow
  0 siblings, 0 replies; 13+ messages in thread
From: Bill Yow @ 1991-09-05 21:00 UTC (permalink / raw)


My 2 cents:

I hate the LRM style.  All uppercase is just horrible in my opinion.  All upper
case is just ugly and is something I wrote with in the first grade.  All upper 
case is also harder to read.

I use all lower case for reserved words and mixed case for user defined identif
iers.

In article <1991Sep5.190551.8272@beaver.cs.washington.edu>, pattis@june.cs.wash
ington.edu (Richard Pattis) writes:
 popular Pascal books.

stuff deleted.

|>   1) Ada's words (whether reserved words or predefined identifiers - see
|> point 2) should be easily identified; they are the landmarks to navigating
|> through programs.  The LRM uses bold-face, but that is not an option for
|> students who write programs using standard text editors. I want to present
|> code in the book using a style that the students can emulate in their
|> programs.  Upper-case words stand out best.
|> 

Why is it important for the reserved words to standout????  The last thing I
want to read is the reserved words when I am reading code!


more stuff deleted.

|> ----------------------------------------------------------------------------
--
|>   Richard E. Pattis			"Programming languages are like
|>   Department of Computer Science	 pizzas - they come in only "too"
|>     and Engineering			 sizes: too big and too small."


						Later,
						Bill Yow
						(713) 283-4051
						yow@sweetpea.jsc.nasa.gov
						byow@mcimail.com

My opinions are my own!			

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-05 21:53 David Eichmann
  0 siblings, 0 replies; 13+ messages in thread
From: David Eichmann @ 1991-09-05 21:53 UTC (permalink / raw)


pattis@june.cs.washington.edu (Richard Pattis) writes:

>  I recently received some reviews for a CS 1 (Introduction to Programming) in
>Ada textbook. I was criticized (to varying degrees) for not typesetting my Ada
>code according to the standard established in the LRM.  I would like to appeal
>to the net for some advice. Should I toss out my own style and typeset my code
>exactly like the LRM?
....
>  1) Ada's words (whether reserved words or predefined identifiers - see
>point 2) should be easily identified; ....

>  2) To beginners, there is little difference between Ada's reserved words
>and the predefined identifiers. ....

>  3) Mixed case identifiers (user defined) are easier to read than all upper-
>case or all lower-case (even with underscores).  ....

   It's my personal belief that a typesetting style should be defined with
a particular goal in mind, and that in the case of that special class of
expression we call programs that goal should be the maximal transferral
of semantic intent for the tokens used.

   Consider first the means of expression that we have in a standard editing
environment - we can capitalize or not, and we can embed underscores.  The
other traditional typsetting mechanisms (bold, underscoring, italics, etc.)
are unavailable.

   Then consider how we examine the actual expression of a program, i.e.,
the statements.  I doubt very much if even CS1 students spend a great deal
of time pondering the meaning of IF as a *token*, whereas the meaning of
CurrentFuelFlashPoint, current_fuel_flash_point, etc. deserves much more
attention.  The reserved words serve as focussing agents for the underlying
abstraction.  The identifiers, constants, and so on convey semantics whenever
they occur.

   This leads to my primary point: ALL CAPS draws attention, but people (and
they are the important readers of programs), with the exception of those
chained to EBCDIC, do not write in all caps, they write in a mixture of
upper and lower case, with the upper case characters usually indicating
some form of semantic boundary.  This implies that CAPS should be used
for tokens providing structure and mixed case for tokens providing semantics.

>  4) I have seen styles ....

   My CS1 students have enough problems dealing with the other issues at
hand to spend a great deal of time reflecting upon which of the various
styles espoused by the text they should select.  It's better to select
some suitable style and concentrate on that.  Leave discussions of style
to some lab period.

- Dave
----
David Eichmann
Dept. of Statistics and Computer Science
West Virginia University                  Phone: (304) 293-3607
Morgantown, WV  26506                     Email: eichmann@a.cs.wvu.wvnet.edu

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-05 23:52 munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!chook.cs.adel
  0 siblings, 0 replies; 13+ messages in thread
From: munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!chook.cs.adel @ 1991-09-05 23:52 UTC (permalink / raw)


On this subject generally, does anyone know of a "pretty printer" for
Ada, which will allow the reader to format code according to preferred
style.

Preferably written in Ada, of course.

I know about the a.pr thing that comes with the Verdix compiler (although
it has a few annoying characteristics, as I remember it), but I don't have
access to that at the moment.

I could write one, but I believe in software re-use. :-)

#######################################################################
#  Andrew Dunstan                   #   There's nothing good or bad   #
#  Department of Computer Science   #   but thinking makes it so.     #
#  University of Adelaide           #                                 #
#  South Australia                  #          - Shakespeare          #
#  net: andrewd@cs.adelaide.edu.au  #                                 #
#######################################################################

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06  2:35 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-d
  0 siblings, 0 replies; 13+ messages in thread
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-d @ 1991-09-06  2:35 UTC (permalink / raw)


Programming style should vary according to the needs of its users.  Beginners
may have different needs from experts; your ALL UPPER CASE FOR KEYWORDS may
be the right way to go because they need the emphasis.

Keywords need de-emphasizing for experts, however, because they've learned
them so well that recognition, understanding, and use of keywords is mostly
automatic and unconscious.  Instead experts need to have the types, variables, 
and so on stand out.

Still, I'd suggest using one of the published style guides.  Beginners need 
to learn to adopt professional habits and tools as soon as possible so they 
won't remain beginners.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 10:25 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!uvaarpa!vger.nsu.edu!g_
  0 siblings, 0 replies; 13+ messages in thread
From: cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!uvaarpa!vger.nsu.edu!g_ @ 1991-09-06 10:25 UTC (permalink / raw)


In article <1991Sep5.190551.8272@beaver.cs.washington.edu>, pattis@june.cs.wash
ington.edu (Richard Pattis) writes:
...
> to the net for some advice. Should I toss out my own style and typeset my cod
e
> exactly like the LRM?
> 
>   Let me first explain what my goals and rationale are, and then you can
> criticize either them, or how I implement them.  I don't want to differ from
...
> 
> Rich
> 
> 
> You can post your advice on the net (other fledgling Ada authors may be
> watching) or send mail to me (indicate whether it is private or repostable).
> -- 
> -----------------------------------------------------------------------------
-
>   Richard E. Pattis			"Programming languages are like
>   Department of Computer Science	 pizzas - they come in only "too"
>     and Engineering			 sizes: too big and too small."

    I've always used the LRM style (or at least the style supported by the
[HUGE] pretty printer at Simtel20).  Although I like to be independent in my
style, I also point out to my students that Ada was made for large,
group-written projects.  Such projects should have a common style; it's just
that sticking with LRM seems to enforce that style.

    Your rationale is fine, but I've found that sticking with a God-like
standard (the LRM) is "comforting" and prevents the spread of style
denominationalism.  


George

George C. Harrison, Professor of Computer Science
Norfolk State University, 2401 Corprew Avenue, Norfolk VA 23504
Internet:  g_harrison@vger.nsu.edu    Phone:  804-683-8654

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 12:50 europa.asd.contel.com!darwin.sura.net!noc.sura.net!haven.umd.edu!cs.wvu.w
  0 siblings, 0 replies; 13+ messages in thread
From: europa.asd.contel.com!darwin.sura.net!noc.sura.net!haven.umd.edu!cs.wvu.w @ 1991-09-06 12:50 UTC (permalink / raw)


andrewd@chook.cs.adelaide.edu.au (Andrew Dunstan) writes:

>On this subject generally, does anyone know of a "pretty printer" for
>Ada, which will allow the reader to format code according to preferred
>style.

>Preferably written in Ada, of course.
...

Check out the ASR at wsmr-simtel20.army.mil:
	PD7:<ADA.ID-FILES>FORMATTER.SID
	PD7:<ADA.ID-FILES>PRET.SID
	PD7:<ADA.ID-FILES>ADAFORM.SID
	PD7:<ADA.ID-FILES>NAPP.SID
are the description files for 4 pretty printers.

- Dave
----
David Eichmann
Dept. of Statistics and Computer Science
West Virginia University                  Phone: (304) 293-3607
Morgantown, WV  26506                     Email: eichmann@a.cs.wvu.wvnet.edu

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 17:48 MARTIN%SCRANTON.BITNET
  0 siblings, 0 replies; 13+ messages in thread
From: MARTIN%SCRANTON.BITNET @ 1991-09-06 17:48 UTC (permalink / raw)


Richard Pattis writes:
>Date: 5 Sep 91 19:05:51 GMT
>From: june.cs.washington.edu!pattis@beaver.cs.washington.edu  (Richard Pattis)
>Subject: Ada micro Style for Programs in Introductory Textbooks
>Message-ID: <1991Sep5.190551.8272@beaver.cs.washington.edu>

  I recently received some reviews for a CS 1 (Introduction to Programming) in
Ada textbook. I was criticized (to varying degrees) for not typesetting my Ada
code according to the standard established in the LRM.
---stuff deleted---

>  1) Ada's words (whether reserved words or predefined identifiers - see
>point 2) should be easily identified; they are the landmarks to navigating
>through programs.  The LRM uses bold-face, but that is not an option for
>students who write programs using standard text editors. I want to present
>code in the book using a style that the students can emulate in their
>programs.  Upper-case words stand out best.

Reserved words provide the structure of the program and must stand out.
Having taught and used both C and Modula-2 which are case-sensitive with
differing requirements on the case for reserved words, I believe that
either all caps (Modula-2) or all lc (C) are equally effective if used
consistently and if they contrast with user-defined words.

>  2) To beginners, there is little difference between Ada's reserved words
>and the predefined identifiers. If I had to place reserved words, predefined
>identifiers, and user defined identifiers into two categories, I would opt to
>place the first two together (have a built-in meaning) rather than the second
>two (the user can choose the meaning).  Certainly this seems true for
identifiers like INTEGER and CONSTRAINT_ERROR. Even for identifiers like POS
>(where there is a good chance a beginner will declare a variable with this
>name), writing POS when used as an attribute (something from Ada) and Pos when
>used as a user declared identifier seems reasonable.

Predefined types (integer, float, etc.) seem to be comfortable using the
style of reserved words but I find myself using user-defined style when I
program as it seems more comfortable to have all the types consistent rather
than distinguishing between pre-defined and user-defined in a series of
declarations.  Text book writers have to worry about such problems but I
tell my students to try to be consistent but that either is acceptable.
C gives no helpful hints as I am convinced that K&R did not have a shift
key when they developed it.

I/O functions should be mixed case.  Pre-defined library units are neither
fully pre-defined nor fully user-defined.  Text book writers need to face
the fact that we now have a third category that, with the concept of re-
usable code becoming an essential consideration, needs to be better handled.

>  3) Mixed case identifiers (user defined) are easier to read than all upper-
>case or all lower-case (even with underscores).  Compare Student_Count and
>StudentCount with STUDENT_COUNT and STUDENTCOUNT. So the problem specific
>words (which are often plentiful, long, and descriptive) should be written in
>mixed case.

I prefer Mixed_Case with underscores.  Long words without breaks (underscores)
make a program look awkward.  Are there still printers out there that only
print CAPS?  We used to have one.  Made reading Modula-2 code difficult.

A consistent style is essential for program clarity.  We use a Language
Sensitive Editor that forces tokens to adhere to our chosen style.  For
Modula-2, it forced CAPS and we adapted our Pascal LSE to produce CAPS.
The LSE for Ada uses lc tokens and it was easier to go with that than to
modify it.  We did modify the Pascal LSE to produce lc tokens to match the
Ada LSE better when we switched to Ada as our primary language.  Both
styles in Pascal were very effective.  Consistency is really the point.

Dennis S. Martin
University of Scranton
martin@jaguar.uofs.edu
martin@scranton.bitnet

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 18:06 agate!bionet!ucselx!sol.ctr.columbia.edu!spool.mu.edu!tulane!uno.edu!JNCS
  0 siblings, 0 replies; 13+ messages in thread
From: agate!bionet!ucselx!sol.ctr.columbia.edu!spool.mu.edu!tulane!uno.edu!JNCS @ 1991-09-06 18:06 UTC (permalink / raw)


In article <1991Sep5.190551.8272@beaver.cs.washington.edu>, pattis@june.cs.wash
ington.edu (Richard Pattis) writes:
>
>  I recently received some reviews for a CS 1 (Introduction to Programming) in
>Ada textbook. I was criticized (to varying degrees) for not typesetting my Ada
>code according to the standard established in the LRM.  I would like to appeal

In general I would suggest that any book teaching a programming language should
try to follow the commonly (!?!?!?) used style guidelines. In the case for Ada,
the guidelines (which I know you are aware, but for completeness sake) are :
  1. reserved words in small case
  2. user defined identifiers in capital case

I do not like these style guidelines, but I follow them when necessary. 

With respect to your style guidelines I do like them with one exception; using
things like Pos for user defined  POS identifiers. Semantics embedded in case
is just to subtle for my stomach.

Jaime Nino
Computer Science
University of New Orleans

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 19:56 munck
  0 siblings, 0 replies; 13+ messages in thread
From: munck @ 1991-09-06 19:56 UTC (permalink / raw)


Pretty Printers!?  We don't need no stinking Pretty Printers!

What I would very much like to see is a Pretty Editor.  One that shows me the
keywords in boldface and the comments in italic (I know, that isn't the way
the LRM does it.)  On the other hand, I don't want to see the underscore that
connects parts of a multi-word identifier.  Student_Count may be easier to
read than STUDENTCOUNT, but Student Count is better yet.  Maybe on a 20%
shaded background to keep happy those who think the apparent blanks will make
it ambiguous.  (I don't.)  Or in a different color.  (Should keywords be in
Ada Green?  What SUN pallett numbers give me that?)

I know, if I buy certain people's products, I get one.  However, I want it to
be WRITTEN IN Ada and with the SOURCE CODE IN THE PUBLIC DOMAIN.

Lots of other features I'd like, such as a continuously-run complexity measure
and a little meter face in the corner with a "too complex" redline.

Bob Munck

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-06 21:09 david.c.willett
  0 siblings, 0 replies; 13+ messages in thread
From: david.c.willett @ 1991-09-06 21:09 UTC (permalink / raw)


In article <1991Sep5.190551.8272@beaver.cs.washington.edu>, pattis@june.cs.wash
ington.edu (Richard Pattis) writes:
> I would like to appeal to the net for some advice. Should I toss out my own 
> style and typeset my code exactly like the LRM?

[ Description of Prattis' goals and alternative style deleted ]

> 
>   4) I have seen styles (out of PARC?) where the case of the first letter is
> used to separate local from non-local accesses. I was planning on mentioning
> this (as well as hungarian notation, which is not so necessary in Ada compare
d
> to C) but not advocating it. Are there other important conventions that I
> should include?
> 
> 
> Rich
> 
> 
> You can post your advice on the net (other fledgling Ada authors may be
> watching) or send mail to me (indicate whether it is private or repostable).

[Rich's sig deleted]

Coding style is clearly a personal thing.  I believe that it is much like 
handwriting.  Each person develops a style of their own but is heavily 
influenced by styles to which they are initially exposed.  In my own case,
I tended to code in a FORTRANesque style until I took my first PASCAL course.
Since PASCAL was free-form, I had to adapt.  I've been following that style
since.

My point is that you should consider the influence of your style on the 
student's coding habits.  My opinion is that you should follow some standard,
preferably the LRM.  If you feel that you cannot for pedagogical reasons, 
****PLEASE SAY SO*** in your text so that the student can make their own 
decision.  I prefer reserved words in boldface and mixed case identfiers.
I believe that this style helps the student learn the symantics of the 
language.  Mixed case for identifiers is more natural (English-like) and
strikes me as less intimidating to the novice.

My introductory texts used this style.  I did not find the lack of "boldface"
on my terminal an impediment.

				Good Luck with THE_BOOK,
					Dave

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Ada micro style for programs in introductory textbooks
@ 1991-09-09 15:31 Frank Pappas
  0 siblings, 0 replies; 13+ messages in thread
From: Frank Pappas @ 1991-09-09 15:31 UTC (permalink / raw)


>  I recently received some reviews for a CS 1 (Introduction to
>Programming) in Ada textbook. I was criticized (to varying degrees) for not
>typesetting my Ada code according to the standard established in the LRM.
>
  First of all Rich, you should thank the reviewers for having read
the book before critiquing it!

>I would like to appeal to the net for some advice.  Should I toss
out my own style and typest my code exactly like the LRM?
>

  I don't understand why so many people feel they have to follow the
LRM conventions for identifiers. Was it really the intetion to make
these conventions the standard? How were they arrived at? Perhaps one
of the distinguished reviewers will let us know what the thinking
was. Since so many people follow the LRM conventions, maybe the
conventions should be reevaluated for Ada 9X.

  Personally, I find the use of all uppercase words difficult to
read except in special cases, e.g. system-dependent identifiers and
pragmas. Using uppercase seems appropriate when someone reading the
program should pay particular attention to these words.

  I view reserved words as signposts that someone reading a program
should be aware of, however, reserved words shouldn't draw attention
away from the rest of the program text. To me, this means lowercase
is appropriate.

  Capitalizing the remaining words seems preferable to writing in a
single case. English text isn't written that way, so it doesn't seem
reasonable that programs should be. All uppercase probably goes
back to the days when keypunches only produced uppercase.

  The book
                 Ada in Practice
                 Christine Ausnit, Norman Cohen,
                 John Goodenough, and Sterling Eanes
                 published by Springer-Verlag, 1985

contains a number of case studies performed for the Army on some
early Ada programs. The authors examined the software and used it as
a source of examples for studies on naming conventions, use of
exceptions, program structure, etc. Although a few years old, I think
the book is still worth reading.

  The chapter on naming conventions is something every programmer should
read. (It's a great source of ideas for coming up with project naming
conventions, etc.) With a reasonable set of naming conventions, a
preference for mixed case becomes obvious. Here's a paragraph from
the chapter:

     "By using mixed case, sequences of initials stand out
      and are not mistaken for words or truncations of words.
      An identifier like BAD_RIS appears to be talking about
      something called a RIS; when written as Bad_RIs, however,
      it more obviously refers to bad R.I.'s. Similarly, plural
      abbreviations like PHYS_IDS are more easily recognized when
      the identifiers are written as Phys_IDs."

  As for what conventions should be used in a text on Ada, I think
any well thought out, consistent convention that the author believes
improves readability is fine. Whether reviewers agree with the
conventions doesn't matter. This is especially true when the ar
has used the conventions in teaching and found them to work well.

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-10  3:47 Robert I. Eachus
  0 siblings, 0 replies; 13+ messages in thread
From: Robert I. Eachus @ 1991-09-10  3:47 UTC (permalink / raw)


     There are style guidelines which are customary, and style
guidelines which are graven in linguistic stone.  For example, in Ada
there are many different layouts used for if statements, but everyone
will flame you if you put "end" and "if;" on different lines.

     When it comes to Ada in textbooks, stick with reserved words in
lower case boldface, identifiers in all capitals, and a fixed width
font.  In programming there is room for much more flexibility, but
most Ada programmers cringe when faced with uppercase reserved words
or lower case attributes.  The rest is personal style.


--

					Robert I. Eachus

with STANDARD_DISCLAIMER;
use  STANDARD_DISCLAIMER;
function MESSAGE (TEXT: in CLEVER_IDEAS) return BETTER_IDEAS is...

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Ada micro Style for Programs in Introductory Textbooks
@ 1991-09-10 16:36 Mr. D. Harter
  0 siblings, 0 replies; 13+ messages in thread
From: Mr. D. Harter @ 1991-09-10 16:36 UTC (permalink / raw)


munck@STARS.RESTON.UNISYS.COM (Bob Munck) writes:
> 
> Pretty Printers!?  We don't need no stinking Pretty Printers!
> 
> What I would very much like to see is a Pretty Editor.  One that shows me the
> keywords in boldface and the comments in italic (I know, that isn't the way
> the LRM does it.)

Whats wrong with GNU emacs or even better GNU epoch (giving multiple fonts 
etc.)? Ok, so there isn't a built in Ada-mode but there'll be one soon ;-)

Does anybody on the net have an Ada-mode for emacs?
-- 
----------------------------------------------------------------------------
                                               |
Darren Harter                                  |
                                               |

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~1991-09-10 16:36 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-09-06 17:48 Ada micro Style for Programs in Introductory Textbooks MARTIN%SCRANTON.BITNET
  -- strict thread matches above, loose matches on Subject: below --
1991-09-10 16:36 Mr. D. Harter
1991-09-10  3:47 Robert I. Eachus
1991-09-09 15:31 Ada micro style for programs in introductory textbooks Frank Pappas
1991-09-06 21:09 Ada micro Style for Programs in Introductory Textbooks david.c.willett
1991-09-06 19:56 munck
1991-09-06 18:06 agate!bionet!ucselx!sol.ctr.columbia.edu!spool.mu.edu!tulane!uno.edu!JNCS
1991-09-06 12:50 europa.asd.contel.com!darwin.sura.net!noc.sura.net!haven.umd.edu!cs.wvu.w
1991-09-06 10:25 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!uvaarpa!vger.nsu.edu!g_
1991-09-06  2:35 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-d
1991-09-05 23:52 munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!chook.cs.adel
1991-09-05 21:53 David Eichmann
1991-09-05 21:00 Bill Yow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox