>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.
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 */
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.
>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! --
>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
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)
>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.
>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
; 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
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
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)
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
>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.
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
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.
>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
>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
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]]);}
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
/* "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
* 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!
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...
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
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
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
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 ***
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
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)
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> *
*****************************************************************************
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
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
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: | |
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
>
> >In article <1993Feb2.1...@spectrum.xerox.com>, hda...@rx.xerox.com
> >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.
> 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_
[...]
>> 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".
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
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...
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
% 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
>(Properly written Pascal should be self-commenting).
Properly written C *is* self-commenting. :-)
--
Dan Griffin In STEREO where available
gri...@egr.msu.edu
(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."
>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. >
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
>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
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
> 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
/*
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
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_
>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
>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...
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.
[ 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
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 */
>/* 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
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>
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.
>>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
>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...
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
>|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
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
#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
The Russian Orthodox Church also keeps to the old ( Julian ? ) calender.
Some members of my families get two Christmas's a year :-)
>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
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)
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>
:-)
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)
--
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
>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.
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.
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
[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
>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)
> } 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
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...
>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)
/*
>/* 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? :-)
>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.
>>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
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