Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

world's worst comment

193 views
Skip to first unread message

Thomas Koenig

unread,
Jan 30, 1993, 11:45:38 AM1/30/93
to
mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:

>Here is my candidate for the world's most useless comment:
>[X-windows C-code generated by XDesigner 2.0 Motif UI builder]

>Display *display; /* Display */

Well... I'm sure the crowd here can do better?
--
Thomas Koenig, ig...@rz.uni-karlsruhe.de, ig...@dkauni2.bitnet
The joy of engineering is to find a straight line on a double
logarithmic diagram.

Tod McQuillin

unread,
Feb 1, 1993, 1:39:26 PM2/1/93
to
ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
> mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:
> >Display *display; /* Display */
>
> Well... I'm sure the crowd here can do better?

This is from a piece of code for a user accounting system I developed.
ten and five were variables to keep track of whether a ten or five
minute warning had been issued, and this code set the flags so that no
warnings would be issued after this point.

ten = five = 1; /* peace = war */

Sergej Roytman

unread,
Feb 1, 1993, 4:05:50 PM2/1/93
to
In article <ig25.728412338@fg70> ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
|mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:
|
|>Here is my candidate for the world's most useless comment:
|>[X-windows C-code generated by XDesigner 2.0 Motif UI builder]
|
|>Display *display; /* Display */
|
|Well... I'm sure the crowd here can do better?

Actually, here's one that appears in my code prettty regularly:

do_stuff(); /* do stuff */

|--
|Thomas Koenig, ig...@rz.uni-karlsruhe.de, ig...@dkauni2.bitnet

--
-----------------------------------------------------------------------
| ft...@engin.umich.edu | "... a stainless steel rat in the |
| (Sergej Roytman) | ferroconcrete wainscoting of Internet" |
-----------------------------------------------------------------------

Say no to four-line .sigs.

Peter Gutmann

unread,
Feb 2, 1993, 5:14:39 AM2/2/93
to

>This is from a piece of code for a user accounting system I developed.
>ten and five were variables to keep track of whether a ten or five
>minute warning had been issued, and this code set the flags so that no
>warnings would be issued after this point.

> ten = five = 1; /* peace = war */

Many years ago when I was forced to program in Pascal, there was one particular
marker who insisted that *everything* have its own const value, no matter how
pointless. So I started out with:

const
zero = 0;
one = 1;
five = 5;

Then I got creative and added things like:

twenty = 15;
oneHundred = 55;
twoThousandFiveHundredAndSixtyTwo = 2;

etc. In all the work I did I almost always lost 5-10% of the total marks due
to doing wierd things like this. The markers must have hated me :-).

Peter.
--
pg...@cs.aukuni.ac.nz||p_gu...@cs.aukuni.ac.nz||gutm...@kosmos.wcc.govt.nz
pet...@kcbbs.gen.nz||pe...@nacjack.gen.nz||pe...@phlarnschlorpht.nacjack.gen.nz
(In order of preference - one of 'em's bound to work)
-- Surgeon-General's Warning: Intel inside! --

Jon Brawn

unread,
Feb 2, 1993, 9:42:29 AM2/2/93
to
ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:

>mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:

>>Here is my candidate for the world's most useless comment:
>>[X-windows C-code generated by XDesigner 2.0 Motif UI builder]

>>Display *display; /* Display */

>Well... I'm sure the crowd here can do better?

Hmmm. I was working on a debugger, originally based on xdb on a BSD4.2 on
a VAX system, when I came across a comment in the memory manager code.

I don't have the code available here to quote from, but the comment was
something to the effect of:


/*
** If I understood this code, I would comment it.
*/


--
Jon Brawn Specialix International, 3, Wintersells Road,
jo...@specialix.co.uk Byfleet, Surrey, KT14 7LF
``The Original Bear'' +44(0)932 354254

Hugh J.E. Davies

unread,
Feb 2, 1993, 11:28:13 AM2/2/93
to


From a PDP-11 based process control system I worked on once (and no,
I am not making this up);

CLR R5 ; Clear R5

---


Regards,

Hugh.
------------------------------------------------------------------
I don't speak for Xerox. | "It's no use being clever - we are all
Rank Xerox Centre, UK. | clever here; just try to be kind - a
Huge...@rx.xerox.com | little kind." (F.J. Foakes Jackson)

Thomas Koenig

unread,
Feb 2, 1993, 11:57:07 AM2/2/93
to
pg...@cs.aukuni.ac.nz (Peter Gutmann) writes:

>const
> zero = 0;
> one = 1;
> five = 5;

>Then I got creative and added things like:

> twenty = 15;
> oneHundred = 55;
> twoThousandFiveHundredAndSixtyTwo = 2;

So who's ever used FORTRAN's infamous 'variation of constants' method?
The program

I = 100
CALL SUB(100)
PRINT *,I
END
SUBROUTINE SUB(I)
I = 50
END

prints out 50 on many platforms. This clearly proves that, at a
metaphysical level, 50 is indeed 100, or can be made so by True FORTRAN
Compilers.

Arlie Davis

unread,
Feb 2, 1993, 2:21:38 PM2/2/93
to
tm...@andrew.cmu.edu (Tod McQuillin) writes:

>This is from a piece of code for a user accounting system I developed.
>ten and five were variables to keep track of whether a ten or five
>minute warning had been issued, and this code set the flags so that no
>warnings would be issued after this point.

> ten = five = 1; /* peace = war */

I found this in my own Korn shell alias file:

alias more=less

I didn't even get the joke for weeks. :)

--
lrwx------ 1 aldavi01 emacsstu 9 Jun 6 12:43 .signature -> /dev/null

Frank - Hardware Hacker - Borger

unread,
Feb 2, 1993, 6:16:00 PM2/2/93
to
In article <ig25.728412338@fg70> ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
|mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:
|
|>Here is my candidate for the world's most useless comment:
|>[X-windows C-code generated by XDesigner 2.0 Motif UI builder]
|
|>Display *display; /* Display */
|
|Well... I'm sure the crowd here can do better?
The source for Spacewar on the PDP-8 had the following series
it isn't quite useless, but give you a certain feeling about the
mental attitude of the programmer. (Those were the days of
tie-dye, wacky tabacky, etc.)

; Is ship number 1 exploding ?
; yes - how exciting
; no - how dull

Frank R. Borger - Physicist ___ George Halas had two heirs; one carried
Michael Reese - U of Chicago |___ his seed and one carried his soul. ...
Center for Radiation Therapy | |_) _ One can imagine the wisper of George
net: Fr...@rover.uchicago.edu | \|_) Halas, rooting for his soul. -
ph: 312-791-8075 fa: 567-7455 |_) Jeannie Morris

Mika Liljeberg

unread,
Feb 3, 1993, 4:45:11 AM2/3/93
to
In article <aldavi01....@starbase.spd.louisville.edu> alda...@starbase.spd.louisville.edu (Arlie Davis) wrote:
> I found this in my own Korn shell alias file:
>
> alias more=less
>
> I didn't even get the joke for weeks. :)

I always use cat, more or less. :-)

Mika
--
Mika Liljeberg Email: lilj...@hydra.Helsinki.FI
Helsinki University Mika.Li...@Helsinki.FI
Dept. of Computer Science

Sarr J. Blumson

unread,
Feb 3, 1993, 9:01:35 AM2/3/93
to
In article <2FEB1993...@rover.uchicago.edu> fr...@rover.uchicago.edu writes:
>|Well... I'm sure the crowd here can do better?
> The source for Spacewar on the PDP-8 had the following series
> it isn't quite useless, but give you a certain feeling about the
> mental attitude of the programmer. (Those were the days of
> tie-dye, wacky tabacky, etc.)
>
> ; Is ship number 1 exploding ?
> ; yes - how exciting
> ; no - how dull
>

One thing worth pointing out (maybe) is that back in the Olden Days
when machines weren't as relaible as they are now (:-)) (especially
when you were so foolish as to try to use the system you were trying
to develop) people sometimes had to type the same code twice. Or 3
times, Or...

I'm sure there were many like me in the habit of writing our
(assembler) code by hand but only commenting it when we typed it. I
know that my own comments got more witty and less useful with each
retyping.

Of course this wouldn;t be an issue today.

(Sarr Blumson)

Michael Ardai

unread,
Feb 3, 1993, 10:21:19 AM2/3/93
to
In article <1993Feb2.1...@specialix.co.uk> jo...@specialix.co.uk (Jon Brawn) writes:
-ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
-
- /*
- ** If I understood this code, I would comment it.
- */


From the core.c module of Teradyne's D300 code, in a routine that does
a backdoor entry into some DEC device driver code to workaround some bug:

/*
* Wierd magic happens here...
*/

char_buff.device_class = 0x60;
char_buff.device_type = 0x04;
char_buff.device_filler = 0xffff;
char_buff.device_dependent = 0x00000000;
SYS$QIOW(0,channel,IO$_SETMODE,&status_blk[0],0,0,&char_buff,0,0,0,0,0);

What is really strange is that we still run this code on a totally rewritten
driver for different hardware, and it hasn't broken anything!

/mike
--
\|/ Michael L. Ardai N1IST Teradyne ATG Boston
--- -------------------------------------------------------------------------
/|\ ar...@maven.dnet.teradyne.com

Bill Parke

unread,
Feb 3, 1993, 11:09:13 AM2/3/93
to

>In article <1993Feb2.1...@spectrum.xerox.com>, hda...@rx.xerox.com (Hugh J.E. Davies) writes:
>Newsgroups: alt.folklore.computers
>Path: nntpd.lkg.dec.com!news.crl.dec.com!deccrl!decwrl!parc!rocksanne!kzin!hdavies
>From: hda...@rx.xerox.com (Hugh J.E. Davies)


>From a PDP-11 based process control system I worked on once (and no,
>I am not making this up);

> CLR R5 ; Clear R5

>---

Betcha it is the same person who wrote

MOV #ARRAY,R5 ; Get base address of array to clear
MOV #0,(R5)+ ; Clear first word of array
MOV #0,(R5)+ ; Clear Second word of array
.
.
.
MOV #0,(R5)+ ; Clear Five hundred and twelfth word of array

in main line code, twice for the same area at different times.

Bill Parke parke%star.e...@decwrl.dec.com
VMS Development decwrl!star.enet.dec.com!parke
Digital Equipment Corp pa...@star.enet.dec.com
110 Spit Brook Road ZK01-2/D59, Nashua NH 03063

The views expressed are my own.


Neville Holmes

unread,
Feb 3, 1993, 6:41:11 PM2/3/93
to
Well, not exactly worst, but .....

There was a story, several decades ago, that, when the legendary certain
decreed that ALL source code had to have at least x% comments, and there
was a checker that blocked your assembly if you didn't.

Well, someone wrote a preprocessor that counted comments, and appended
the lacking comments as * MICKEY MOUSE (No lower case in those days!)

The authorities woke up to this, and upgraded the checker not to count
repeated comments. So the preprocessor was upgraded to alternate
MICKEY MOUSE with DONALD DUCK. Of course.

I never did hear following episodes ! ?

BTW, I used to go to user group meetings at one stage, and one special
interest group used to get amusement from tracking the career of
a programmer whose signature was branching around equates. They never
even thought of telling tales.
--
-------------------------------------------------------------------------------
Neville Holmes AARNET: Neville...@appcomp.utas.edu.au
Dept of Applied Computing & Maths Phone : +61 03 243 393 or (003) 243 393
University of Tasmania - Launceston Fax : +61 03 243 368 or (003) 243 368

Andreas Meyer

unread,
Feb 3, 1993, 8:16:17 PM2/3/93
to
In alt.folklore.computers, pg...@cs.aukuni.ac.nz (Peter Gutmann) writes:
> Many years ago when I was forced to program in Pascal, there was one
> particular marker who insisted that *everything* have its own const value,
> no matter how pointless.

How strange. Your pens speak to you??! ;-)

> So I started out with:
>
> const
> zero = 0;
> one = 1;
> five = 5;
>
> Then I got creative and added things like:
>
> twenty = 15;
> oneHundred = 55;
> twoThousandFiveHundredAndSixtyTwo = 2;
>
> etc. In all the work I did I almost always lost 5-10% of the total marks due
> to doing wierd things like this. The markers must have hated me :-).

I don't think so, since everyone knows, that's not elegant. :-)

When I was a Comp.Sci. major, each programming assignment got two grades,
one for being "correct" (ie. operated to spec, got the proper results)
and the other for "elegance" (an interesting mix of criteria, including
economic use of variables and system resources; and is the code
nice to look at?)

Andy
--
Andreas Meyer, N2FYE a...@spatula.rent.com You can't grep dead trees.

Jim Frost

unread,
Feb 3, 1993, 5:02:26 PM2/3/93
to
mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:

>Here is my candidate for the world's most useless comment:
>[X-windows C-code generated by XDesigner 2.0 Motif UI builder]

>Display *display; /* Display */

I ran into the following one:

int i[100]; /* an array */

What it really was was a buffer into which was put a stack frame that
was built on the fly and linked into the actual hardware stack to
allow backtracing across an interrupt frame on the IBM RT. You
wouldn't believe how hard it was to figure that out from looking at
the source code.

My favorite very accurate comment is a function header comment:

/* [explanatory comment deleted]
*
* BUGS
* Beyond human comprehension. Extremely fragile.
*
* [other bugs deleted]
*
* If you need to change this code, talk to me. - [name deleted]
*/

You really don't want to know what *that* function does.

jim frost
ji...@centerline.com

Bernd Felsche

unread,
Feb 4, 1993, 4:30:14 AM2/4/93
to
>tm...@andrew.cmu.edu (Tod McQuillin) writes:

>I found this in my own Korn shell alias file:

> alias more=less

>I didn't even get the joke for weeks. :)

Nor did I until my korn shell wasn't started but I got:

SO and SE were previously defined as standout and standout-end tputs.
# set the korn shell prompt
if [ -t 0 -a -t 1 ] ; then
HOST=`uuname -l`
[ -w / ] && X=\# || X=\$
[ "$TERM" ] && SE=`tput rmso` SO=`tput bold`
PS1='$HOST:$SO${PWD}$SE$X '
fi

[ If you don't get the "joke", read the PS1 definition without $'s ]
--
+-----+ Bernd Felsche _-,_|\ #include <std/disclaimer.h>
| | | | MetaPro Systems Pty Ltd / | \ ber...@metapro.DIALix.oz.au
| | | | 328 Albany Highway, X_.'-._/ Fax: +61 9 472 3337
|m|p|s| Victoria Park, Western Australia 6100 v Phone: +61 9 362 9355

Joseph H Allen

unread,
Feb 4, 1993, 4:20:26 PM2/4/93
to
In article <UfPKtSi00...@andrew.cmu.edu> Tod McQuillin <tm...@andrew.cmu.edu> writes:
>ig...@fg70.rz.uni-karlsruhe.de (Thomas Koenig) writes:
>> mor...@sitka.triumf.ca (Morgan Burke) writes in comp.lang.c:
>> >Display *display; /* Display */
> ten = five = 1; /* peace = war */

Reminds me of:

RESTRT EQU *
ORCC $50
LDS #STACKE
CLR ERROR * Baptise the system
...

--
/* jha...@world.std.com (192.74.137.5) */ /* Joseph H. Allen */
int a[1817];main(z,p,q,r){for(p=80;q+p-80;p-=2*a[p])for(z=9;z--;)q=3&(r=time(0)
+r*57)/7,q=q?q-1?q-2?1-p%79?-1:0:p%79-77?1:0:p<1659?79:0:p>158?-79:0,q?!a[p+q*2
]?a[p+=a[p+=q]=q]=q:0:0;for(;q++-1817;)printf(q%79?"%c":"%c\n"," #"[!a[q-1]]);}

Chris Cannam

unread,
Feb 4, 1993, 5:02:17 AM2/4/93
to


I noticed this one just now in the source for xman:


/* Function Name: CreateManpage
* Description: Creates a new manpage.
* Arguments: none.
* Returns: none.
*/

Widget
CreateManpage( file )
FILE * file;
{
...


--
on sighting mathematicians it should unhook the algebra from their
minds and replace it with poetry; on sighting poets it should
unhook poetry from their minds and replace it with algebra

Bruce Tindall

unread,
Feb 4, 1993, 6:04:02 PM2/4/93
to

At the top of the code for an interpreter I saw the comment:

/* "You should need no interpreter" -- Thomas Stearns Eliot */

and later, at the top of the main loop where it starts to
execute the instructions:

/* "Bloody instructions which return to plague the inventor..."
-- William Shakespeare */

(They're from "Old Possum's Book of Practical Cats" and "Macbeth,"
respectively.)

In another piece of software, a user in the field reported that
the message "BUG 3 HIT" had been displayed. The developers looked
through the code to find where the message came from, and right
above it was the comment: "/* Should never happen */"

One product I was using once displayed the following message:

UNABLE TO DISPLAY
THIS GRAPH BECAUSE:
1. (We will fill in
2. the reasons when
3. we figure them out.)
--
Bruce Tindall, Core Testing Mgr., SAS Institute Inc., Cary, N.C. 27513

David Brooks

unread,
Feb 4, 1993, 1:44:56 PM2/4/93
to
Way back, a wizard at Xerox Data Systems put together a device driver
for a Case Vista 2, a block-mode CRT. Like any device driver, it was
quite hairy, but it had one comment.

* THE FOLLOWING INSTRUCTIONS CHECKS PARITY. HOW IT DOES SO IS LEFT AS
* AN EXERCISE FOR THE READER.

The following instruction was an EBS: decimal-mode Edit Byte String.
Don't ask.
--
David Brooks dbr...@osf.org
Open Software Foundation uunet!osf.org!dbrooks
Shine out, fair sun, with all your heat! Black winter freezes to his seat...
The boneless fish close quaking lies...the stars in icicles arise!

Jeff DelPapa

unread,
Feb 5, 1993, 2:09:44 AM2/5/93
to
In article <C1y5E...@unx.sas.com> sas...@jjoyce.unx.sas.com (Bruce Tindall) writes:
>
>At the top of the code for an interpreter I saw the comment:
>
> /* "You should need no interpreter" -- Thomas Stearns Eliot */
>
>and later, at the top of the main loop where it starts to
>execute the instructions:
>
> /* "Bloody instructions which return to plague the inventor..."
> -- William Shakespeare */
>
>(They're from "Old Possum's Book of Practical Cats" and "Macbeth,"
>respectively.)

The old RT-11 source was full of pithy quotes ---

Some of my favorites...

Above the idle loop was

; "He did nothing at all, and he did it very well"
; --from HMS Pinafore

and above the trap handler that caught timer events, after the OS had
halted...

; "the death of god left the angels in a strange position"
; -- Neitzche

there were a fair number of others -- when dec started distributing
source to rt-11 in the standard kit, they unfortunately stripped all
the comments off to get it to fit onto the small drives of the day...

If someone still has a full source kit for rt (they were there for 2c
I think) would care to add some more...

linda.b.dunlap

unread,
Feb 5, 1993, 11:30:10 AM2/5/93
to
I worked on a project within AT&T where we were REQUIRED to comment every
line of code. We had to use 132 column screens and comments had to start
at some column (don't remember where). This was in the early days of C
and I guess they did it because there weren't too many experts around.

In some ways it was helpful. The comments read like pseudo code.

Diversion (Jeff Rogers)

unread,
Feb 5, 1993, 1:30:29 PM2/5/93
to
l...@cbnews.cb.att.com (linda.b.dunlap) writes:

What about if your pseudo-code reads like code?

In silly-CS classes, we were required to write pseudo code, which, at times
helpful, is an annoyance for a 'hello, world' program. So, my pseudo code
was very often code with semicolons stripped, == changed to =, etc.

main
char *x="hello, world"
call printf(*x)
done

Ok, so that's a bad example (kinda looks like pseudo-FORtrash). But, a
longer example would take up too much space, so I'll skip it.

Diversion
--
"I can see 'em | "Want me to create a diversion?"
I can see 'em | Diversion
Someone wake me when it's over" | rog...@rpi.edu

Don Stokes

unread,
Feb 5, 1993, 7:19:59 PM2/5/93
to
sas...@jjoyce.unx.sas.com (Bruce Tindall) writes:
> One product I was using once displayed the following message:
>
> UNABLE TO DISPLAY
> THIS GRAPH BECAUSE:
> 1. (We will fill in
> 2. the reasons when
> 3. we figure them out.)

Powerhouse has a graphing package of sorts which I saw demoed once. It
would do its best to display graphs on whatever device you had; clearly
it would prefer a graphics terminal or printer, but would make do with
a text terminal.

If you asked it for a histogram, it would do just fine. But things like
pie graphs were a bit of a problem.

If you did ask for a pie graph, it would draw all the "furniture" around
the space for the graph, then in the middle of the space write:


imagine a circle.


--
Don Stokes, ZL2TNM (DS555) d...@zl2tnm.gen.nz (home)
Network Manager, Computing Services Centre d...@vuw.ac.nz (work)
Victoria University of Wellington, New Zealand +64-4-495-5052

Anno Siegel

unread,
Feb 6, 1993, 7:52:16 AM2/6/93
to

I once had an AIM 65 computer (it's still around). It's a 6502 based
thingie and came with full documentation: circuit diagram of the
hardware, commented assembly listing of the operating system and more.
Apparently programmers were required to put a comment next to virtually
any instruction they wrote. This led to some silly comments, and I seem
to remember that my favorite was (INX increments one of the registers)

INX ;must be done

To my dismay I wasn't able to find that line again. Can someone
confirm/debunk?
--
Anno Siegel sie...@zrz.tu-berlin.de
c/o TU-Berlin/ZRZ s=siegel ou=zrz p=tu-berlin a=dbp c=de
*** Disclaimer disclaiming to disclaim the usual disclaimer ***

gunde...@desire.wright.edu

unread,
Feb 6, 1993, 4:21:07 PM2/6/93
to
In article <=3134=q...@rpi.edu>, rog...@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
> l...@cbnews.cb.att.com (linda.b.dunlap) writes:
>
>>I worked on a project within AT&T where we were REQUIRED to comment every
>>line of code. We had to use 132 column screens and comments had to start
>>at some column (don't remember where). This was in the early days of C
>>and I guess they did it because there weren't too many experts around.
>
>>In some ways it was helpful. The comments read like pseudo code.
>
> What about if your pseudo-code reads like code?
>
> In silly-CS classes, we were required to write pseudo code, which, at times
> helpful, is an annoyance for a 'hello, world' program. So, my pseudo code
> was very often code with semicolons stripped, == changed to =, etc.
>
> main
> char *x="hello, world"
> call printf(*x)
> done


psuedo code is really a pain for really short programs, as you mentioned, but
for nice long programs (oh, say over 1000 lines) it's almost nesescary! you
try to write a program in straight code over 1000 lines long and never write
any psuedo code! if you can, show me and i'll be mucho-impressed!

-Greg

FICHTNER

unread,
Feb 6, 1993, 5:03:43 PM2/6/93
to
In article <1993Feb2.1...@cs.aukuni.ac.nz> pg...@cs.aukuni.ac.nz (Peter Gutmann) writes:
>Many years ago when I was forced to program in Pascal, there was one particular
>marker who insisted that *everything* have its own const value, no matter how
>pointless. So I started out with:
>
>const
> zero = 0;
> one = 1;
> five = 5;
>
>Then I got creative and added things like:
>
> twenty = 15;
> oneHundred = 55;
> twoThousandFiveHundredAndSixtyTwo = 2;
>
>etc. In all the work I did I almost always lost 5-10% of the total marks due
>to doing wierd things like this. The markers must have hated me :-).
>

This is similar to what I did when asked not-terribly-nicely to comment
Pascal code for a class I took in H.S. :( I've got a habit of
only commenting something when I know I won't understand it in 2 years.
so, anyway... we'd get something like this:

Program TakeThis; (* declares program name to compiler *)

var (* variable declaration section *)
(* That, by the way, was a comment, describing a part of the program
this is ALSO a comment. just so that you know. *)
a,b,c:integer; (* three integer variables *)

const (* constant declaration section *)
d=45; (* declare d as 45 for the entire program *)

begin (* a begin statment *)
writeln('Enter three values here: '); (* prompt *)
(* read three values from the user *)
readln(a,b,c);
writeln(a*b*c*d); (* do stuff *)
end. (* an end statment. Note the period. *)

(* This is a comment as well, just in case you didn't remember.
This is what happens when a non-commenter is required to
comment code that is so pathetically easy to understand,
it doesn't need comments *)


Needless to say, the teacher was NOT impressed. the program
worked as required, but he couldn't FIND it in the six pages
of printout that got handed in. (the code itself took about
a page and a half to write, whatever the puny assignment was)

Michael T Pins

unread,
Feb 6, 1993, 7:00:14 PM2/6/93
to
gunde...@desire.wright.edu writes:

Depends on what language you are programming in. When I was taking CS courses,
I was known to write a 1500 line program from scratch, and have it functional
and bug-free in under 8 hours. Obviously no psuedo code was ever written. As
this was in Pascal, it didn't need any comments, much less psuedo code.
(Properly written Pascal should be self-commenting).
--
*****************************************************************************
* Michael Pins | Internet: ami...@isca.uiowa.edu *
* ISCA's Amiga Librarian | #include <std.disclaimer> *
*****************************************************************************

Daniel P. B. Smith

unread,
Feb 6, 1993, 10:14:35 PM2/6/93
to
On the PDP-1 assembler, op codes and addresses were just symbols that
were or'ed together and could appear in any order. That is,
"lac foo" (load AC with contents of address "foo") was conventional,
but "foo lac" was also legal. Eric Jensen was fond of choosing address
symbols that would combine with op codes in interesting ways, and sometimes
exploited this in combination with the freedom to have the address precede
the opcode. I seem to recall
id iot
and
emp: pe ror

and things of that sort.

I think Pete Samson's TJ-2 type justifier had comments in it like
"The ways of God are just and can be justified to man," and "Girls
who wear pants should be sure that the end justifies the jeans."

I think the RT-11 code that maintained the time of day had some comment
like "The important thing about a clock is not to run extremely fast,
but to keep the right time."


--
Daniel P. B. Smith
dpbs...@world.std.com

Todd R. Eigenschink

unread,
Feb 6, 1993, 8:24:36 PM2/6/93
to
>In article <1993Feb6.1...@desire.wright.edu> gunde...@desire.wright.edu writes:
>In article <=3134=q...@rpi.edu>, rog...@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
>> l...@cbnews.cb.att.com (linda.b.dunlap) writes:
>>
>> [misc deleted...]

>>
>> What about if your pseudo-code reads like code?
>>
> [more misc deleted...]

>
>psuedo code is really a pain for really short programs, as you mentioned, but
>for nice long programs (oh, say over 1000 lines) it's almost nesescary! you
>try to write a program in straight code over 1000 lines long and never write
>any psuedo code! if you can, show me and i'll be mucho-impressed!
>
>-Greg


If you really want it, I'll send you the source (all 6000 lines of it)
that implement the compiler I designed (in my head) last winter for
the compilers class I took... Granted, I'm not saying that it was a
_good_idea_, but I did it...and I've even fixed it since, a whole year
later.

--
Todd Eigenschink (eige...@CS.Rose-Hulman.Edu)
Rose-Hulman Institute of Technology, Terre Haute, IN
"You know what? I am a complete moron. Feel free to hit me." -- Joel Klein

Paul Carter

unread,
Feb 7, 1993, 8:39:13 AM2/7/93
to

One of the worst but most disarmingly honest comments I have seen resides in
the source for Unix Version 6 (NOTE: that's Version 6 (1979?), not
System 6 (1999?) ).

In the midst of some difficult code we have:

/*
* If the new process paused because it was
* swapped out, set the stack level to the last call
* to saveu(u_ssave). This means that the return
* which is executed immediately after the call to aretu
* actually returns from the last routine which did
* the savu.
*
* You are not expected to understand this.
*/


P A U L P A U L P A U L P A U L P A U L
C A R T E R C A R T E R C A R T E R C A R T E R C A R T E R
3d signature 3d signature 3d signature 3d signature 3d signature
Focus lines: | |

--
P A U L P A U L P A U L P A U L P A U L
C A R T E R C A R T E R C A R T E R C A R T E R C A R T E R
3d signature 3d signature 3d signature 3d signature 3d signature
Focus lines: | |

Phill Hallam-Baker

unread,
Feb 7, 1993, 4:19:48 PM2/7/93
to
In article <1993Feb6.2...@nmsu.edu>, efic...@dante.nmsu.edu (FICHTNER)
writes:

Unless you are doing something incredibly complex then the only bits of code
that realy need documenting are the interfaces. If what you are doing *is*
complex then maybee a bit more modularization is in order.

One of the languages I wrote I considered removing the comment feature. This was
because practicaly evey construct incorporated documentation comments. This was
so we could produce the docs from the system from the code. So for instance to
declare an input field you might use:-

ROUTINE fred "FRED"
DESCRIPTION
|Produces a fredable object on the screen. The user may then interact
|with the fred object using the functions CHOCKY and PENELOPE.
INTEGER START
MINIMUM 0
COMMENT
|The initial value of the FRED object.

Note that these are not "comments" because they are integral to the user
interface. If the user asks for help on an input (eg presses "help" button under
motif) then the text from the COMMENT or DESCRIPTION field is used.

The idea of removing the line mode comments was that it would then ensure that
all the comment info would be avaliable online. However since forcing the
programmer never works I dropped the idea.

--

Phill Hallam-Baker

Daniel Drucker

unread,
Feb 7, 1993, 7:24:21 PM2/7/93
to
pa...@uselss.enet.dec.com (Bill Parke) writes:

> >Newsgroups: alt.folklore.computers


>
> >From a PDP-11 based process control system I worked on once (and no,
> >I am not making this up);
>
> > CLR R5 ; Clear R5

I remember once seeing the following line in a C=64 program:

70 PRINT "WHAT IS YOUR NAME?" : REM PRINTS "WHAT IS YOUR NAME?"

--
Daniel Drucker N2SXX | The number PI (3.14...) and all included
daniel%mer...@uunet.uu.net | digits are (C) 1993 by BigCorp, and use
und...@vaxc.hofstra.edu | without written consent is prohibited.

Matthias Neeracher

unread,
Feb 8, 1993, 5:43:07 PM2/8/93
to
In article <1993Feb6.1...@desire.wright.edu>, gunde...@desire.wright.edu writes:
> In article <=3134=q...@rpi.edu>, rog...@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
>> l...@cbnews.cb.att.com (linda.b.dunlap) writes:
>>
>>>I worked on a project within AT&T where we were REQUIRED to comment every
>>>line of code.
>>>[...]
>>>In some ways it was helpful. The comments read like pseudo code.
>>
>> What about if your pseudo-code reads like code?
>>
>> In silly-CS classes, we were required to write pseudo code, which, at times
>> helpful, is an annoyance for a 'hello, world' program. So, my pseudo code
>> was very often code with semicolons stripped, == changed to =, etc.
>>
>> main
>> char *x="hello, world"
>> call printf(*x)
>> done

> psuedo code is really a pain for really short programs, as you mentioned, but
> for nice long programs (oh, say over 1000 lines) it's almost nesescary! you
> try to write a program in straight code over 1000 lines long and never write
> any psuedo code! if you can, show me and i'll be mucho-impressed!

Another sad example of the disastrous effects that software engineering
literature can have on an impressible young mind :-)

I have never written a line of pseudo code for my programs, and some of them
worked anyway. (If you need an example, read
software/mac/src/mpw_c/GUSI_102.sit.bin on nic.switch.ch, which is slightly
more than 9000 lines of code). I'm sure most of the other readers here have
written much bigger programs without pseudo code, nassi-shneiderman (sp?)
diagrams, jackson diagrams, or flowcharts. I suspect that all of these tools
might have their uses in multi-person projects, but for one person projects, a
programming language suited to the task and a methodical coding style will do.

Matthias

-----
Matthias Neeracher ne...@iis.ethz.ch
"There once was an Age of Reason, but we've progressed beyond it."
-- Ayn Rand, _Atlas Shrugged_

Karthik P Sheka

unread,
Feb 8, 1993, 8:56:22 PM2/8/93
to
In article <NEERI.93F...@iis.ethz.ch> ne...@iis.ethz.ch (Matthias Neeracher) writes:
>In article <1993Feb6.1...@desire.wright.edu>, gunde...@desire.wright.edu writes:
>> In article <=3134=q...@rpi.edu>, rog...@aix.rpi.edu (Diversion (Jeff Rogers)) writes:
>>> l...@cbnews.cb.att.com (linda.b.dunlap) writes:
>>>>I worked on a project within AT&T where we were REQUIRED to comment every
>>>>line of code.
>>>>[...]
>>>>In some ways it was helpful. The comments read like pseudo code.

[...]

>> psuedo code is really a pain for really short programs, as you mentioned, but
>> for nice long programs (oh, say over 1000 lines) it's almost nesescary! you
>> try to write a program in straight code over 1000 lines long and never write
>> any psuedo code! if you can, show me and i'll be mucho-impressed!
>
>Another sad example of the disastrous effects that software engineering
>literature can have on an impressible young mind :-)
>
>I have never written a line of pseudo code for my programs, and some of them
>worked anyway. (If you need an example, read
>software/mac/src/mpw_c/GUSI_102.sit.bin on nic.switch.ch, which is slightly
>more than 9000 lines of code). I'm sure most of the other readers here have
>written much bigger programs without pseudo code, nassi-shneiderman (sp?)
>diagrams, jackson diagrams, or flowcharts. I suspect that all of these tools
>might have their uses in multi-person projects, but for one person projects, a
>programming language suited to the task and a methodical coding style will do.

Pseudo-code is something you write on a piece of scrap paper, to make sure
your pointers are all pointing in the right directions. It's not something
that should be typed into the computer.

I don't concider myself a god-like programmer, but the project I'm
currently working on is running at about 40000 lines of code (about 1 meg
of source, and going strong) with minimal comments running through the
code. Minimal being a few lines per function plus some extra comments
within complex algorithms, to give hints as to what is going on. How do we
manage? Well, we're writing it in C++, so we just have to release our
class structures to each other, and we have programmers meetings every
week, to discuss major design issues, and send email or talk to each other
to go over minor implementation details. We don't have flow charts (we're
using a GUI as a front end, so tracking flow is somewhat ridiculous),
pseudocode (as long as the interface works, we don't worry about each
other's code), or much in the way of diagrams. The only close coordination
we have is at compilation time, to make sure that no two persons are trying
to compile the program at the same time. :-)

What I've noticed from non-Computer Science programmers, is that they tend
to write very few/long functions. I admit that writing pseudocode for
these types of programs would be useful, but CS majors tend to write
functions under 100 lines each, and have a good idea of modular
programming. Pseudocode would be useless, because either the code is
self-evident, or it's so complex that you have to prepend documentation
about the function.

Karthik Sheka | It's not an optical illusion. It just looks like
k...@cunixb.cc.columbia.edu | one.
kar...@cs.columbia.edu | By "recursion" I mean "defined by recursion".

Shyamal Prasad

unread,
Feb 8, 1993, 11:43:16 PM2/8/93
to
In article <1993Feb9.0...@news.columbia.edu> k...@cunixb.cc.columbia.edu (Karthik P Sheka) writes:
>What I've noticed from non-Computer Science programmers, is that they tend
>to write very few/long functions. I admit that writing pseudocode for
>these types of programs would be useful, but CS majors tend to write
>functions under 100 lines each, and have a good idea of modular
>programming. Pseudocode would be useless, because either the code is
>self-evident, or it's so complex that you have to prepend documentation
>about the function.

In fact, I would suggest that if a function gets longer than a screen
you should see if you are going wrong. On my system a screen
is about 48 characters (an X terminal, and I use emacs), and I try to
write functions smaller than this.

No dogma .... but I tend to believe a 100 lines is too much :-)
Of course I have no major programming experience - never written
programs with more than 10,000 lines (and *never* worked on a team).

Well, that's my bit .....
Shyamal

--
Shyamal Prasad, Department of Computer Science
Southern Methodist University, Dallas TX 72275

circuit

unread,
Feb 9, 1993, 2:24:43 AM2/9/93
to
From article <1993Feb9.0...@news.columbia.edu>, by k...@cunixb.cc.columbia.edu (Karthik P Sheka):

> What I've noticed from non-Computer Science programmers, is that they tend
> to write very few/long functions. I admit that writing pseudocode for
> these types of programs would be useful, but CS majors tend to write
> functions under 100 lines each, and have a good idea of modular
> programming. Pseudocode would be useless, because either the code is
> self-evident, or it's so complex that you have to prepend documentation
> about the function.
>

I'm an MIS major but I learned to program on my own in junior high
and through the computer science department at my school. Thank God!

To look at other people's code in my MIS classes, was sheer horror !
I would run screaming from the room as if I just saw Cuthul....

I just could not understand WHY people wrote code the way they did!

The funny thing is is that the MIS professor stressed modularity and
functions with very few lines of code.


oh well...

C()
--
cir...@convex.csd.uwm.edu

Paul Repacholi

unread,
Feb 9, 1993, 10:27:54 AM2/9/93
to
Well nearly ALL PDP-6/10 macro had the same first line...

Reset ; reset the world


And of course the fortran compiler one note ONE=1 comment,

[ something I can't remember ] = ^D1000 ; rip jsb

Worse, it WAS meaningfull.. sort of

~Paul

Henry Troup

unread,
Feb 9, 1993, 12:39:59 PM2/9/93
to
One of my own:

% close the file,
% then reopen as the non-existent file.
% thus ... finds the right files, and no real rename is needed!
%
% (At no time do the fingers leave my hand!)

Henry Troup - H.T...@BNR.CA (Canada) - BNR owns but does not share my opinions
onotology recapitulates

Danny Griffin

unread,
Feb 9, 1993, 5:55:51 PM2/9/93
to
mtp...@icaen.uiowa.edu (Michael T Pins) writes:

>(Properly written Pascal should be self-commenting).

Properly written C *is* self-commenting. :-)
--
Dan Griffin In STEREO where available
gri...@egr.msu.edu

Ernest A. Cline

unread,
Feb 9, 1993, 9:40:05 PM2/9/93
to

First mtp...@icaen.uiowa.edu (Michael T Pins) wrote:

(Properly written Pascal should be self-commenting).

Causing gri...@egr.msu.edu (Danny Griffin) to write:

Properly written C *is* self-commenting. :-)

Which lead me to observe that:

Most written C code is self-committing. 8-D
--
Ernest Cline cl...@cs.scarolina.edu
"They're coming to take me away, ha ha, he he, ho ho, to the funny farm."

Michael Welsh Duggan

unread,
Feb 9, 1993, 9:56:55 PM2/9/93
to

Would that be Rest In Peace, Johann Sebastion Bach?


Michael Welsh Duggan
md...@cmu.edu

Dan Sorenson

unread,
Feb 10, 1993, 4:03:26 AM2/10/93
to
In <griffin.729298551@msuinfo> gri...@egr.msu.edu (Danny Griffin) writes:

>Properly written C *is* self-commenting. :-)

Care to read mine? It's all taken directly from either source
for BSD 4.3 Unix or the K&R manual. Trust me, there is no less
than three megabytes of the stuff. You have six weeks to start
patching it. Want the job? It pays $8.00/hr, and is part-time only.

I think this makes the case for the next guy understanding
your code, no matter how elegant/inelegant it is or what language
it might be in. I've seen convoluted C, but I've seen even worse
BASICk and FORTRAsh. A pity those kids never learned...

< Dan Sorenson, DoD #1066 z1...@exnet.iastate.edu vik...@iastate.edu >
< ISU only censors what I read, not what I say. Don't blame them. >
< USENET: Post to exotic, distant machines. Meet exciting, >
< unusual people. And flame them. >

Rich Strebendt

unread,
Feb 10, 1993, 6:33:00 PM2/10/93
to
In article <18...@bcars664.bnr.ca>, h...@bcarh11a.BNR.CA (Henry Troup) writes:
> One of my own:
>
> % close the file,
> % then reopen as the non-existent file.
> % thus ... finds the right files, and no real rename is needed!
> %
> % (At no time do the fingers leave my hand!)

My favorite comment was one that appeared as the only comment in a
substantial assembler language routine. In the midst of the code was
one line of code that seemed to have no reason to be there. It
carried a single word as its comment. The word: "Subtle" . As far
as I know, no-one has tried to remove that line of code!

Rich Strebendt
...!att!ihlpb!res
r.str...@att.com

Bernd Felsche

unread,
Feb 11, 1993, 10:29:25 PM2/11/93
to


>One of the worst but most disarmingly honest comments I have seen resides in
>the source for Unix Version 6 (NOTE: that's Version 6 (1979?), not
>System 6 (1999?) ).

>In the midst of some difficult code we have:

>/*
> * If the new process paused because it was
> * swapped out, set the stack level to the last call
> * to saveu(u_ssave). This means that the return
> * which is executed immediately after the call to aretu
> * actually returns from the last routine which did
> * the savu.
> *
> * You are not expected to understand this.
> */

The explanation I understand... it makes perfect sense
to do it that way.

As for the code, I've never seen it.
--
+-----+ Bernd Felsche _-,_|\ #include <std/disclaimer.h>
| | | | MetaPro Systems Pty Ltd / | \ ber...@metapro.DIALix.oz.au
| | | | 328 Albany Highway, X_.'-._/ Fax: +61 9 472 3337
|m|p|s| Victoria Park, Western Australia 6100 v Phone: +61 9 362 9355

Phill Hallam-Baker

unread,
Feb 11, 1993, 3:19:03 PM2/11/93
to
In article <NEERI.93F...@iis.ethz.ch>, ne...@iis.ethz.ch (Matthias
Neeracher) writes:

How about the people who wrote a 1000 line program rather than a 10,000 line
program because they used a programming tool?

I have a program which has declined from 10,000 lines of code six months ago to
under 3000 today despite the functionality being increased. The point is that if
you think about your problem the code can usualy be kept to a reasonable size
instead of ballooning into something ridiculous.


The problem with flowcharts, Jackson diagrams etc is that they are not
particularly good programming aids. Modern systems like Z, VDM, CSP etc are much
better. Hooked up to powerful code synthesizers such as goedel you can write the
program direct from a high level specification.

--

Phill Hallam-Baker

Zhenya Gorokhovsky

unread,
Feb 12, 1993, 3:47:03 AM2/12/93
to
r...@cbnewsc.cb.att.com (Rich Strebendt) writes:


> My favorite comment was one that appeared as the only comment in a
> substantial assembler language routine. In the midst of the code
> was one line of code that seemed to have no reason to be there. It
> carried a single word as its comment. The word: "Subtle" . As far
> as I know, no-one has tried to remove that line of code!

11: If it ain't broken, don't fix it.
Zhenya

Jeff Weisberg

unread,
Feb 12, 1993, 12:16:15 PM2/12/93
to
One of my favorite's is from a piece of code I wrote
for a multiprocessing embedded control device. In the code
that awakens sleeping processes:

/*
frere a jacques, frere a jacques
dormez-vous?, dormez-vous?
*/
for(jacques=1;jacques<N_PROC;jacques++)
if(proc[jacques].sleep) proc[jacques].sleep--;


--jw

Bob Stearns

unread,
Feb 12, 1993, 2:21:04 PM2/12/93
to
My first job, many years ago, in a galaxy far away, was to debug the
Disk Operating System for the IBM 1620. We had two disks and could only
address one of them logically through the OS. We knew the second was
working because direct addressing the disk worked. You need to have a
little of the architecture of the machine to appreciate the problem. We
had a large one, 60,000 digits (not characters) of memory, a printer in
addition to the typewriter, etc. The entire OS was overlayed into 2000
digits of memory just above the add/multiply tables (it couldn't add
directly in the hardware). The machine supported unlimited levels of
address indirection. Down in the middle of the dispatcher was an
indirect branch with the comment "WHITHER WANDEREST THOU WAYFARER". It
was one of the few comments in the entire routine.
--
Bob Stearns
University of Georgia
i...@groucho.dev.uga.edu
(404)542-5110

Rich Alderson

unread,
Feb 12, 1993, 2:09:17 PM2/12/93
to

Decimal 1000 (^D1000) equals octal 1750. Usually, when something needed to be
done 1000 times, a constant was assigned with the value in octal (the normal
base in the assembler), and the comment was actually fairly frequent.
--
Rich Alderson 'I wish life was not so short,' he thought. 'Languages take
such a time, and so do all the things one wants to know about.'
--J. R. R. Tolkien,
alde...@leland.stanford.edu _The Lost Road_

Charlie Gibbs

unread,
Feb 12, 1993, 4:12:47 PM2/12/93
to
In article <1993Feb9.0...@seas.smu.edu> shy...@seas.smu.edu
(Shyamal Prasad) writes:

>In fact, I would suggest that if a function gets longer than a screen
>you should see if you are going wrong. On my system a screen
>is about 48 characters (an X terminal, and I use emacs), and I try to
>write functions smaller than this.

For the first five or six years of my career I didn't have
terminals to play with. Everything was done on cards. :-p Even
after I got onto machines with terminals and on-line editors, we'd
work from marked-up paper listings. We would still write code on
paper and type it in, and debugging would be done on paper (from
printed program output and memory dumps).

It's only over the last few years that I've started working
completely through a screen. When you're working with a paper
listing you can easily flip quickly through it, scribble notes in
the margins, etc. On a screen (at least on systems I work on)
you can only see 24 lines at a time, instead of a hundred or so.

I've been noticing an interesting effect on my coding style.
In the past I thought nothing about single modules hundreds of lines
long; by flipping a couple of pages I could rapidly scan the whole
thing. Now, though, I find my modules are starting to shorten.
If the most you want to page through is two or three screenfuls
or pages to see an entire module, a 24-line screen will keep your
modules down to less than a quarter the size of what you'd accept
on paper.

>No dogma .... but I tend to believe a 100 lines is too much :-)

No dogma here, either. I still write the occasional long
module. Sometimes they "just grow" due to incomplete specs.
But I've definitely noticed a trend in my coding towards smaller
modules, which I believe is caused by these little screens.
Nevertheless, I wouldn't give up terminals and text editors
for the world.

>Of course I have no major programming experience - never written
>programs with more than 10,000 lines (and *never* worked on a team).

I've gotten up into the 5000-line range a number of times, and
my OS/3 assembler totals 16,000 lines if you add up all the overlays
(does that count?). If I did that old stuff all over again it would
probably look VERY different. On the other hand, I came through the
GOTO witch-hunts of the '70s relatively unscathed; if your programs,
in your style, work better than theirs with all the latest comp-sci
fads, you'll piss off a lot of zealots - but when it comes down to
the crunch they'll have to put up with you. Besides, these concepts
work a lot better in modern languages; you can't write GOTOless COBOL
without getting really bent out of shape, and (much to these types'
distress) there's still a lot of COBOL out there.

As for working on a team, I've always managed to see the work
divided such that a programmer is completely responsibe for an
individual program. I believe that if a program is too big for
one person to write, it should be broken down into several smaller
programs. But then, that's just modularity on another level,
isn't it?

Charli...@mindlink.bc.ca
"It's lonely here, there's no one left to torture." -- Leonard Cohen

Matthew Alderson

unread,
Feb 14, 1993, 8:33:55 PM2/14/93
to
alde...@cisco.com (Rich Alderson) writes:

>In article <1993Feb10...@cc.curtin.edu.au>, zrepachol@cc (Paul Repacholi) writes:
>>Well nearly ALL PDP-6/10 macro had the same first line...

>>[ something I can't remember ] = ^D1000 ; rip jsb
>>
>>Worse, it WAS meaningfull.. sort of

>Decimal 1000 (^D1000) equals octal 1750. Usually, when something needed to be

the rip jsb refers to Johan Sobastien Bach. I recall reading about this
somewhere once before...

W. Douglas West

unread,
Feb 15, 1993, 12:01:16 AM2/15/93
to
In article <thecure.729740035@coombs> the...@coombs.anu.edu.au
Johann Sebastian Bach, 1685-1750.

W. Douglas West


Paul Carter

unread,
Feb 15, 1993, 6:48:04 AM2/15/93
to
Bernd Felsche (ber...@metapro.DIALix.oz.au) wrote:

: In <1993Feb7.1...@unisys.co.nz> car...@unisys.co.nz (Paul Carter) writes:
:
:
: >One of the worst but most disarmingly honest comments I have seen resides in
: >the source for Unix Version 6 (NOTE: that's Version 6 (1979?), not
: >System 6 (1999?) ).
:
: >In the midst of some difficult code we have:
:
: >/*
: > * If the new process paused because it was
: > * swapped out, set the stack level to the last call
: > * to saveu(u_ssave). This means that the return
: > * which is executed immediately after the call to aretu
: > * actually returns from the last routine which did
: > * the savu.
: > *
: > * You are not expected to understand this.
: > */
:
: The explanation I understand... it makes perfect sense
: to do it that way.


Q.E.D. :-) :--) :---) :----)


: As for the code, I've never seen it.

I lied when I used the quod erat demonstrandum, the situation is
more complex than that.

When I first read the comment, I thought I understood the explanation ... until
I got to the part that questioned my understanding of it.

Indeed, the comment was correct, I really didn't understand the subtle code
surrounding it. The challenge was irresistable, and after a few hours
I managed to figure it out.

This was the first time I'd come across a comment that actually caused
enlightenment to be significantly delayed, not enhanced !!!


Postscriptum
The code is from /usr/sys/ken/slp.c of 1975 vintage.

Guy Dawson

unread,
Feb 15, 1993, 5:18:21 PM2/15/93
to

[ Lots of stuff about using an 80x24 screen and keeping the module size down
so it fits in a screen ].

I currently [ 10 seconds ago ] writing and application on an Xterminal.

The font size os Rom8, the window is 176x77! People roun here think I'm
made to use such a small font but I like it!

I've got 3 windows open ( two in read only mode ) on the same
source file.

It makes life *SOOOOOOOOOOOOOO* easy.
I would say that it has increased my output ( lines of debugged code )
by at least 30%.

If ever there way a cost justification for giving progrmammers
Xterminals, this alone is it!

For the editor? vi of course :-)

As for the effects of newsfeeds on programmers - no comment :-)

--------------------------------------------------------------------------------
Guy Dawson - Hoskyns Group Plc.
gu...@hoskyns.co.uk Tel Hoskyns UK - 71 251 2128
gu...@austin.ibm.com Tel IBM Austin USA - 512 838 3377
"Knolege is powef, Speling is unimportnt" via Pete W. De Bonte


Charlie Gibbs

unread,
Feb 16, 1993, 6:46:32 PM2/16/93
to
/* Sometimes when I'm calculating dates I'm too lazy (or
ornery) to just use a table of days per month, and I
come up with the following appropriately-commented code: */

int dayspermonth (int year, int month)
{
if ((month == 9) /* Thirty days hath September, */
|| (month == 4) /* April, */
|| (month == 6) /* June, */
|| (month == 11)) { /* and November. */
return (30);
} else if (month != 2) { /* All the rest have thirty-one, */
return (31);
} else { /* Except for February alone, */
if ((year % 4) != 0)
return (28); /* Which has but 28 days clear, */
else
return (29); /* And 29 in each leap year. */
}
}

/* Charli...@mindlink.bc.ca
"I'm cursed with hair from HELL!" -- Night Court */

Diversion (Jeff Rogers)

unread,
Feb 16, 1993, 8:31:42 PM2/16/93
to
Charli...@mindlink.bc.ca (Charlie Gibbs) writes:

>/* Sometimes when I'm calculating dates I'm too lazy (or
> ornery) to just use a table of days per month, and I
> come up with the following appropriately-commented code: */

>int dayspermonth (int year, int month)
>{
> if ((month == 9) /* Thirty days hath September, */
> || (month == 4) /* April, */
> || (month == 6) /* June, */
> || (month == 11)) { /* and November. */
> return (30);
> } else if (month != 2) { /* All the rest have thirty-one, */
> return (31);
> } else { /* Except for February alone, */
> if ((year % 4) != 0)

What about the gregorian calendar?

> return (28); /* Which has but 28 days clear, */
> else
> return (29); /* And 29 in each leap year. */
> }
>}

It seems this could be implemented differently, perhaps more effectively, in
a switch. (Of course, that's completely subjective). Or, even better:

#define daysperyear(x,y) (x==9||x==4||x==6||x==11?30:x!=2?31:y%4?28:29)

Or, more compactly:

#define daysperyear(x,y) (x-9&&x-4&&x-6&&x-11?x-2?y%4?28:29:31:30)

Someone want to check these to see if they actually work?

Diversion

--
"I can see 'em | "Want me to create a diversion?"
I can see 'em | Diversion
Someone wake me when it's over" | rog...@rpi.edu

Alec Muffett - Sun IS - System Administrator

unread,
Feb 17, 1993, 5:34:54 AM2/17/93
to
leaps years are defined as years, the number for which
- is divisible by 4
- unless it is divisible by 100
- except when divisible by 400

so the leapyear test is

#define FEBDAYS(y) ((y%4)?28:((y%100)?29:((y%400)?28:29)))

- add optimisation as necessary.

---
Alec Muffett (alec.m...@sun.co.uk) Sun Microsystems IR, Bagshot, Surrey, UK
#include <stddisclaimer.h>


Jeff Weisberg

unread,
Feb 17, 1993, 3:59:44 PM2/17/93
to
In article <1lt4ce...@uk-news.uk.sun.com> al...@coyote.uk.sun.com writes:
/* leaps years are defined as years, the number for which
/* - is divisible by 4
/* - unless it is divisible by 100
/* - except when divisible by 400

but, of course we need to take into account the Gregorian reformation:
thus if its before 1752, only if it is divisible by 4

/* so the leapyear test is
/*
/* #define FEBDAYS(y) ((y%4)?28:((y%100)?29:((y%400)?28:29)))

#define FEBDAYS(y) ((y>1752)?(y%4)?28:((y%100)?29:((y%400)?28:29)):(y%4)?28:29)

--jw.

Mark Harrison

unread,
Feb 17, 1993, 4:25:49 PM2/17/93
to

>>One of the worst but most disarmingly honest comments I have seen resides in
>>the source for Unix Version 6 (NOTE: that's Version 6 (1979?), not
>>System 6 (1999?) ).

I like the comment in the nawk lexer. After a block copy and hack
of the yyinput, etc, macros:

/* God help us all if anyone changes how lex works. */
--
Mark Harrison, mhar...@dsccc.com

Charlie Gibbs

unread,
Feb 17, 1993, 10:39:44 PM2/17/93
to
In article <___4t...@rpi.edu> rog...@aix.rpi.edu
(Diversion (Jeff Rogers) writes:

>Charli...@mindlink.bc.ca (Charlie Gibbs) writes:

[compilable message deleted]

>What about the gregorian calendar?

Spoilsport. :-)

>It seems this could be implemented differently, perhaps more effectively, in
>a switch. (Of course, that's completely subjective). Or, even better:
>
>#define daysperyear(x,y) (x==9||x==4||x==6||x==11?30:x!=2?31:y%4?28:29)
>
>Or, more compactly:
>
>#define daysperyear(x,y) (x-9&&x-4&&x-6&&x-11?x-2?y%4?28:29:31:30)

Cute. But you'd have a hard time fitting the comments in...

Ernest Cline

unread,
Feb 17, 1993, 10:53:36 PM2/17/93
to
weis...@ee.rochester.edu (Jeff Weisberg) writes:

Two quibbles.
1> Not everyone lives in an English speaking country where the conversion
to Gregorian occured in 1752.
2> You don't need to check for Gregorian until after you've determined that
the year is divisble by 4.

#define GREGORY(y) (y>1752) /* Really should use localization */
#define FEBDAYS(y) ((y%4)?28:(GREGORY(y)?((y%100)?29:((y%400)?28:29)):29))

--
Ernest Cline cl...@cs.scarolina.edu Professional Grad Student

Alec Muffett - Sun IS - System Administrator

unread,
Feb 18, 1993, 3:57:31 AM2/18/93
to
In article 7300...@usceast.cs.scarolina.edu, cl...@cs.scarolina.edu (Ernest Cline) writes:
>weis...@ee.rochester.edu (Jeff Weisberg) writes:
>|In article <1lt4ce...@uk-news.uk.sun.com> al...@coyote.uk.sun.com writes:
>|> leaps years are defined as years, the number for which
>|> - is divisible by 4
>|> - unless it is divisible by 100
>|> - except when divisible by 400
>|> #define FEBDAYS(y) ((y%4)?28:((y%100)?29:((y%400)?28:29)))

>|but, of course we need to take into account the Gregorian reformation:


>| thus if its before 1752, only if it is divisible by 4

>|#define FEBDAYS(y) ((y>1752)?(y%4)?28:((y%100)?29:((y%400)?28:29)):(y%4)?28:29)

>Two quibbles.
>1> Not everyone lives in an English speaking country where the conversion
> to Gregorian occured in 1752.
>2> You don't need to check for Gregorian until after you've determined that
> the year is divisble by 4.

Bother! I knew I'd forgotten something. You're right. However, in the
Faeroe Islands and (I think) Albania, perhaps one or two other places,
they never adopted the gregorian calendar at all.

Their "christmas day" (25th Dec) is way out w.r.t the rest of the
world, like on January 12th, or something. How does ANSI-C cope with
this degree of localisation, or is it something else they missed ? 8-)

- alec

Brian Cooper

unread,
Feb 18, 1993, 12:37:57 PM2/18/93
to
In article <thecure.729740035@coombs> the...@coombs.anu.edu.au (Matthew Alderson) writes:

Try "Techniques of Program Structure and Design", by Edward Yourdon, pp.
10-11. (Prentice-Hall, 1975)

"Unfortunately, many programmers seem to write comments as personal
messages to themselves, that is, to remind themselves of the purpose of
the particular instruction or program statement they used. The personal
note, though, may be completely indecipherable to anyone else, and even
the original programmer may have difficulty understanding the meaning of
the comment (as well as the statement that it accompanies, of course) at
some later time. An interesting example of this occurred several years
agon when a lone superpprogrammer single-handedly developed a FORTRAN II
compiler for a well-known computer manufacturer. After he tested the
compiler and turned it over to his manager, the programmer disappeared
for several days, during which time the manager discovered that there
were some bugs that required immediate attention. The junior programmer
assigned to find and fix the bugs discovered, to his horror, that the
entire compiler contained only ONE comment, which accompanied an octal
constant in the following manner:

CONST23: 3443 ;R.I.P.L.V.B.

Since the superprogrammer had a reputation for brevity as well as
brilliance, the junior programmer began to think that perhaps this
single comment would unlock all the mystteries of the compiler. After
several hours of pondering the meaning of the comment, he finally hit on
the answer--the number 3443, in octal, is equivalent to the number 1827
in decimal. Being a classical music fan ... and a collector of trivial
information, the junior programmer happened to remember that 1827 was
the year Beethoven died! As one might imagine, the programming manager
was quite unamused by all of this, and when the superprogrammer
reappeared, he was asked to take his inestimable talents elsewhere."

I highly recommend the book for A.F.C fans -- it has a number of good
stories in it.


--
Brian Cooper b...@Eyring.COM
Eyring Corp. +1 801-375-2434 or 1 800 YES PDOS

Vadim Antonov

unread,
Feb 18, 1993, 5:10:01 PM2/18/93
to
Howabout the tightest code to calculate the number of days in a month?

#define DAYS(y, m) ((m)-2||((y)%4)||!((y)%100)&&((y)%400)&&(y)>1752?\
"\0\37\34\37\36\37\36\37\37\36\37\36\37"[m]:29)

C can be nearly as neat as troff :-)

--vadim

Guy Dawson

unread,
Feb 18, 1993, 6:51:05 PM2/18/93
to

The Russian Orthodox Church also keeps to the old ( Julian ? ) calender.

Some members of my families get two Christmas's a year :-)

Charlie Gibbs

unread,
Feb 18, 1993, 8:02:25 PM2/18/93
to
In article <1993Feb17....@ee.rochester.edu>
weis...@ee.rochester.edu (Jeff Weisberg) writes:

>/* leaps years are defined as years, the number for which
>/* - is divisible by 4
>/* - unless it is divisible by 100
>/* - except when divisible by 400

Oh my God, I've resurrected the leap year thread!

Mea culpa. Mea maxima culpa.

>but, of course we need to take into account the Gregorian reformation:
> thus if its before 1752, only if it is divisible by 4

And, of course, it totally disregards the missing 11 days.

Charli...@mindlink.bc.ca
"Graphical user interfaces make simple things simple
and complicated things impossible."
-- Marty Leisner (in a letter to UnixWorld, January 1993)

Martin Pauley

unread,
Feb 19, 1993, 1:19:26 AM2/19/93
to
In article <cline.7...@usceast.cs.scarolina.edu>,

cl...@cs.scarolina.edu (Ernest Cline) wrote:
>Two quibbles.
>1> Not everyone lives in an English speaking country where the
>conversion to Gregorian occured in 1752.
>2> You don't need to check for Gregorian until after you've determined
>that the year is divisble by 4.

Another quibble:

This is the year 5 of Heisei. Who's gonna tell Gregory?

:-)

--------------------------------
.Marty.!
Lost in Space! (or is it Japan?)
<pau...@tai.jkj.sii.co.jp>

Ross Smith

unread,
Feb 20, 1993, 6:36:16 AM2/20/93
to
In article <21...@mindlink.bc.ca> Charli...@mindlink.bc.ca (Charlie Gibbs) writes:
>/* Sometimes when I'm calculating dates I'm too lazy (or
> ornery) to just use a table of days per month, and I
> come up with the following appropriately-commented code: */
>
>int dayspermonth (int year, int month)
>{
> if ((month == 9) /* Thirty days hath September, */
> || (month == 4) /* April, */
> || (month == 6) /* June, */
> || (month == 11)) { /* and November. */
> return (30);
> } else if (month != 2) { /* All the rest have thirty-one, */
> return (31);
> } else { /* Except for February alone, */
> if ((year % 4) != 0)
> return (28); /* Which has but 28 days clear, */
> else
> return (29); /* And 29 in each leap year. */
> }
>}

:-)

Um ... you do realise this only works from 1901 to 2099, I suppose?

--
...... Ross Smith (Wanganui, NZ) ...... al...@acheron.amigans.gen.nz ......
"I blame you for the moonlit sky and the dream that died with the Eagle's flight
I blame you for the moonlit nights when I wonder why are the seas still dry
Don't blame me, sleeping satellite" (Tasmin Archer)
--

Kenneth Freeman

unread,
Feb 20, 1993, 4:48:54 AM2/20/93
to
pau...@tai.jkj.sii.co.jp (Martin Pauley) writes:


22 February 1993 is the beginning of Royal Tibetan Year 2120,
the Water-Bird-Year.

--
INTERNET: kf...@netlink.cts.com (Kenneth Freeman)
UUCP: ...!ryptyde!netlink!kfree
NetLink Online Communications * Public Access in San Diego, CA (619) 453-1115

Harri Haanp{{

unread,
Feb 21, 1993, 2:15:30 PM2/21/93
to
In <1m11fp...@rodan.UU.NET> a...@rodan.UU.NET (Vadim Antonov) writes:

>Howabout the tightest code to calculate the number of days in a month?

>#define DAYS(y, m) ((m)-2||((y)%4)||!((y)%100)&&((y)%400)&&(y)>1752?\
> "\0\37\34\37\36\37\36\37\37\36\37\36\37"[m]:29)

This fails miserably for September 1752 at least, doesn't it?

How about this:

#define DAYS(y, m) ((m)-2?30+(5546>>(m)&1):29-((y)%4||!((y)%100)&&(y)%400))

This, too, fails for September 1752 but it's a lot shorter..

Harri H.

Martin Hay

unread,
Feb 22, 1993, 9:21:48 AM2/22/93
to

September 1752 is a SICK month, and I'll deck anyone who says otherwise :-)

Anyone who rips 12(?) days out of a month seriously needs to seek psychiatric
help.

Martin Hay.

Shankar Unni

unread,
Feb 22, 1993, 12:37:22 PM2/22/93
to
Martin Hay (m...@dcs.ed.ac.uk) wrote:

Well, it was a classic example of "the longer you put it off, the more
painful it gets".

The larger part of the Christian world moved back in 15??, when Pope
Gregory VII proposed the new calendar. The Protestant world put it off
until 1752. The Russians put it off until 1923(?), which made it even worse
(which is why they had an "October Revolution" on November 11).

Could have been worse, I suppose: the Egyptians once had a problem where
their calendar got so far behind that they were celebrating "summer
solstice" on the coldest day of the year..
--
Shankar Unni E-Mail: sha...@sgi.com
Silicon Graphics Inc. Phone: +1-415-390-2072

Ray, just Ray

unread,
Feb 23, 1993, 1:38:07 AM2/23/93
to
al...@acheron.amigans.gen.nz (Ross Smith) notes, quite concerned :-)
>Charli...@mindlink.bc.ca (Charlie Gibbs) get's creative and functional:

[edited for economic bandwith recuction for a better America :-]

>Um ... you do realise this only works from 1901 to 2099, I suppose?

And you think this _matters_?!?!?! By 2099, we'll all be dead, and C will be
as common as core memory. Oh, I forgot about the space shuttle....never mind!

--
Ray E. Saddler III ___ ___ ___ ___ ___ "they say Confucius
P.O. Box 24346 M/S 2L-21 /__// //__ / /\ // _ does his crossword
Seattle, WA 98124-0346 USA /__//__//__ _/_ / //__/ with a pen" Tori
sad...@bcstec.ca.boeing.com Computer Services "Hello Earth!" KaTe

Megan B Gentry

unread,
Feb 23, 1993, 11:26:29 AM2/23/93
to
dpbs...@world.std.com (Daniel P. B. Smith) writes:

>I think the RT-11 code that maintained the time of day had some comment
>like "The important thing about a clock is not to run extremely fast,
>but to keep the right time."

The RT-11 sources are a lot of fun to look through because they are
littered with very literate (and mostly applicable) quotes from things.

For example, the section of code which handle termination of a user
job has a quote from the Mikado:

"Behold the lord high executioner, a personage of
noble rank and title..."

I'll try to get a few more of them together for listing here.

Megan Gentry
former RT-11 Developer
(But I'll never let go of my -11's)

Leonhard Bauer

unread,
Feb 23, 1993, 12:55:57 PM2/23/93
to
In article <21...@mindlink.bc.ca> Charli...@mindlink.bc.ca
(Charlie Gibbs) wrote:

> } else { /* Except for February alone, */
> if ((year % 4) != 0)
> return (28); /* Which has but 28 days clear, */
> else
> return (29); /* And 29 in each leap year. */
> }
> }

Not every year divisible by four is a leap year. Even if this code
will not produce errors during the next 106 years, the leap year
detection works a bit different:

If the year is divisible by 4 it is a leap year.
It it's a multiple of 100, then it isn't a leap year.
If it's a multiple of 400, then it'll be a leap year again.

So 2000 will be a leap year, but 2100 won't.

--
'Leo'nhard Bauer * l...@yrb.incubus.sub.org

Ross Smith

unread,
Feb 24, 1993, 6:50:35 PM2/24/93
to
In article <C2w2F...@bcstec.ca.boeing.com> sad...@bcstec.ca.boeing.com (Ray, just Ray) writes:
>al...@acheron.amigans.gen.nz (Ross Smith) notes, quite concerned :-)
>>Charli...@mindlink.bc.ca (Charlie Gibbs) get's creative and functional:
>
>[edited for economic bandwith recuction for a better America :-]
>
>>Um ... you do realise this only works from 1901 to 2099, I suppose?
>
>And you think this _matters_?!?!?! By 2099, we'll all be dead, and C will be
>as common as core memory. Oh, I forgot about the space shuttle....never mind!

The 2099 end might not matter yet, but the 1901 end does! I cut code for the
Ministry of Transport (driver's licences etc.), and we have to worry about
dates of birth that start with 18...

P. J. Remner

unread,
Feb 24, 1993, 9:03:46 AM2/24/93
to

In a previous article, ber...@metapro.DIALix.oz.au (Bernd Felsche) says:

>In <1993Feb7.1...@unisys.co.nz> car...@unisys.co.nz (Paul Carter) writes:
>
>>/*
>> * If the new process paused because it was
>> * swapped out, set the stack level to the last call
>> * to saveu(u_ssave). This means that the return
>> * which is executed immediately after the call to aretu
>> * actually returns from the last routine which did
>> * the savu.
>> *
>> * You are not expected to understand this.
>> */
>
>The explanation I understand... it makes perfect sense
>to do it that way.
>

>As for the code, I've never seen it.
>

Who needs to see the code? This comment is posted approx. 500 times a year
in alt.folklore.computers!

--
aj...@cleveland.freenet.edu (Pneumatic polyurethane)
/*

P. J. Remner

unread,
Feb 24, 1993, 9:10:35 AM2/24/93
to

In a previous article, Charli...@mindlink.bc.ca (Charlie Gibbs) says:

>/* Sometimes when I'm calculating dates I'm too lazy (or
> ornery) to just use a table of days per month, and I
> come up with the following appropriately-commented code: */
>
>int dayspermonth (int year, int month)
>{
> if ((month == 9) /* Thirty days hath September, */
> || (month == 4) /* April, */
> || (month == 6) /* June, */
> || (month == 11)) { /* and November. */
> return (30);
> } else if (month != 2) { /* All the rest have thirty-one, */
> return (31);
> } else { /* Except for February alone, */
> if ((year % 4) != 0)
> return (28); /* Which has but 28 days clear, */
> else
> return (29); /* And 29 in each leap year. */
> }
>}


Not to burst thy bubble, but if it's a "century year" (i.e. 1700, 1800...)
it has to be divisible by 400, also. This means that 1900 wasn't a leap
year, even though it is divisible by 4. 2000 is safe, but won't you want
your code to last until at least 2100? :-)

Charlie Gibbs

unread,
Feb 24, 1993, 7:55:14 PM2/24/93
to
In article <1mfvkr...@usenet.INS.CWRU.Edu>

aj...@cleveland.Freenet.Edu (P. J. Remner) writes:

>In a previous article, Charli...@mindlink.bc.ca (Charlie Gibbs) says:

[my compilable Usenet posting deleted]

>Not to burst thy bubble, but if it's a "century year" (i.e. 1700, 1800...)
>it has to be divisible by 400, also. This means that 1900 wasn't a leap
>year, even though it is divisible by 4. 2000 is safe, but won't you want
>your code to last until at least 2100? :-)

I'm quite aware of the limitations of my little bit of code.
Given the stability of a typical user's specifications, I'll no
doubt be in the program making major modifications long before
its accuracy runs out, and I can take care of it then, if the
program isn't replaced first. As is, it's going to last through
2099. I probably won't - so why worry? :-)

Charli...@mindlink.bc.ca
If your nose runs and your feet smell, you're built upside-down.

Russell Schulz

unread,
Feb 26, 1993, 1:52:02 AM2/26/93
to
Charli...@mindlink.bc.ca (Charlie Gibbs) writes:

>>year, even though it is divisible by 4. 2000 is safe, but won't you want
>>your code to last until at least 2100? :-)
>

> program isn't replaced first. As is, it's going to last through
> 2099. I probably won't - so why worry? :-)

I think every leap year test I've coded looks like this:

daysinmonth[2] := 28;
if (year mod 4)=0 then
daysinmonth[2] := 29; { good through 2099 }
--
Russell Schulz rus...@alpha3.ersys.edmonton.ab.ca ersys!rschulz Shad 86c

Frank - Hardware Hacker - Borger

unread,
Mar 1, 1993, 5:16:00 PM3/1/93
to
Just read the following in the code for a Maxim evaluation
board containing a d/a and micro to let any ascii device talk to it.

HEART_BEAT macro
if ROM
cpl b_TIC-TOC ; Keep the watch dog's heart beating .
else
nop ; Let sleeping
nop ; dogs lie.
endif
endm

Frank R. Borger - Physicist ___ George Halas had two heirs; one carried
Michael Reese - U of Chicago |___ his seed and one carried his soul. ...
Center for Radiation Therapy | |_) _ One can imagine the wisper of George
net: Fr...@rover.uchicago.edu | \|_) Halas, rooting for his soul. -
ph: 312-791-8075 fa: 567-7455 |_) Jeannie Morris

0 new messages