Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uwm.edu!spool.mu.edu!uunet!pdn!tscs!tct!chip From: chip@tct.uucp (Chip Salzenberg) Newsgroups: comp.object Subject: Re: Documenting OO Systems Keywords: operators Message-ID: <27F4D3F3.6CD@tct.uucp> Date: 30 Mar 91 18:07:46 GMT References: <1991Mar26.191259.14470@i88.isc.com> <4693@osc.COM> Organization: Teltronics/TCT, Sarasota, FL Lines: 35 According to jls@rutabaga.Rational.COM (Jim Showalter): >>One thing i like about C is that when you type something you know what it's >>going to do. > >Okay, what is this going to do?: > > int j (int y, int m, int d) { > int m_d[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; > if (m<1 || m>12) return 0; > int l = !(y%4) && y&400; > if (d<1 || d>(m_d[m-1] + (m==2 && y))) return 0; > int dd = 0; > for (int i=0; i return dd + d + (m>2 && y); > } Actually, this code isn't legal C, what with the declarations in the middle of the function. And it's badly formatted. And it has a bug or two -- I think the two "&& y" phrases should be "&& l". And the rule for leap years is "(y%4)==0 && ((y%100)!=0 || (y%400)==0". Nevertheless, it is easily recognized as the classic month/day/year to Julian day conversion, with zero as the error return. >You should be able to tell me right off the bat--you think English sucks >as a programming language, and this is DEFINITELY not written in English. Sigh. Jim, you fell victim to one of the classic blunders: "English = Bad" does NOT necessarily imply "!English = Good". -- Chip Salzenberg at Teltronics/TCT , "All this is conjecture of course, since I *only* post in the nude. Nothing comes between me and my t.b. Nothing." -- Bill Coderre