LETTERS

Ada 95 Classes

Dear DDJ,

I read with interest the article "Object-Oriented Facilities in Ada 95," by David L. Moore (DDJ, October 1995). It is good to see the discussion of a fine programming language.

However, Moore's statement that "Line'Class and Object'Class represent the same type; there is one class-wide type for any tree of derivations, rather than one for every subtree" is contrary to fact. There is indeed a class-wide type for every subtree. If Object and Line are defined as in Example 1, then you can access the Offset field of a value of type Line'Class. Doing so with a value of type Object'Class would cause a compilation error, for Object types do not have an Offset field.

Ray Blaak

blaak@mda.ca

Prime Time Again

Dear DDJ,

First, may I congratulate DDJ on the 20th anniversary of what must be the best programming magazine on the market.

I particularly enjoyed the September 1995 issue, not only for the interesting articles (including the one on animation, a subject I will explore in the not-too-distant future), but also for the gems that appear in the mailbag. The letter I'm thinking of in particular is that from Dwight Keeve about prime numbers. He is right to point out that Michael Swaine got his numbering wrong, but, as Daniel Pfeffer pointed out in his January 1996 letter, Keeve's alternative is wrong too--57 is not a prime number because it is divisible by three.

As a nonmathematician, I don't claim any special expertise in this respect. However, I have found that the "ABC" rule serves me well in programming--"Accept nothing, Believe nothing, Check everything." Consequently, I consulted The Mathematical Experience, by Philip J. Davis and Reuben Hersh (Houghton Mifflin, 1982). On page 211, the authors set out the first 2500 prime numbers in a handy table. The extract in Table 1 shows the sequence for the first 20.

In The Hitchhiker's Guide to the Galaxy, the answer to the great question of life, the universe, and everything else is said to be 42. This information probably has about as much usefulness, but I thought it was worth setting the record straight.

Maurice Arnold

Victoria, Australia

Patented Passwords

Dear DDJ,

I'd like to make two points regarding the "Algorithm Alley" column "Password Generation by Bloom Filters," by William Stallings (DDJ, August 1994). First, the title is incorrect. The article describes how to use Bloom filters to constrain the user's choice of passwords, but not to generate the password. Secondly, readers should be aware of U.S. patent 5204,966 issued in 1993 to Digital Equipment Corp., with myself and Jerry Leichter (leichter@lrw .com) as inventors. DEC also applied for a patent in several other countries.

That patent, "a method for constraining the selection of passwords," covers systems such as the one described in Mr. Stallings' article.

David Wittenberg

dkw@cs.brandeis.edu

A Popular Algorithm

Dear DDJ,

The popularity algorithm for color quantization discussed in "The Popularity Algorithm," by Dean Clark ("Algorithm Alley" DDJ, July 1995) is of historical interest, but other algorithms, such as the median-cut algorithm (Heckbert, SIGGRAPH '82) are just as fast, only slightly harder to implement, and produce better pictures. As I wrote in my 1982 paper, the popularity algorithm does a good job on many pictures, but performs poorly on pictures with a wide range of colors or when quantizing to a small number of colors (< 50, say). The visible flaws might be insignificant on many synthetic images of the type displayed in Clark's article, but they can be very objectionable on real images. Also, it is well known that dithering can improve the appearance of quantized pictures dramatically--a fact Clark didn't mention.

The implementations described by myself and others use hashing techniques, lookup tables, and other data structures that speed up histogram collection and nearest-neighbor finding by an order of magnitude (see http://www.cs.cmu.edu/~ph). My 1982 implementation of the median-cut algorithm could quantize a 640x480 picture in 60 seconds on a 1-MIPS VAX 780; current workstations can run the same algorithm in just a few seconds.

Paul Heckbert

Carnegie Mellon University

Pittsburgh, Pennsylvania

ph@cs.cmu.edu

Majority Rule

Dear DDJ,

What I have to say has nothing to do with algorithms or paradigms, or even computers. When John Travis, whom I don't know at all, says (as quoted in Jonathan Erickson's November 1995 "Editorial") "I can't believe that we are going to let a majority of the people decide what's best for this state," he is actually a bit right. The majority of a given population rarely has a chance to objectively focus on a political subject. Nor is it in the layman's interest. Politicians have an obligation to provide the public with information allowing it to form an opinion without having to know the deepest truth. The problem is then that politicians have learned to use this to seduce the public and form sentimental opinions in their own favor. That is why the majority can actually become dangerous. A singer once sang: "Are the many the brightest or are they merely more than the few?" (The translation doesn't do him justice, I'm afraid.)

Thomas Honore Nielsen

Esbjerg Handelsskole, Denmark

<thn.cls@pip.dknet.dk>

Online Educational Alternatives

Dear DDJ,

Thanks for mentioning the University of Missouri's Center for Independent Study in the "Programmer's Bookshelf" (DDJ, September 1994) on nontraditional education alternatives.

In case someone asks about our BBS and examinations, some additional information might be useful. The BBS at the end of our 800 number for computer-assisted learning (CALS) is designed to respond only to students sending in a CALS lesson. The program will accept their answers to the questions given at the end of a lesson, and send back the professor's responses to each incorrect answer.

Students wishing to send in lessons for courses which are not CALS (for example, writing courses) have other alternatives, including fax and e-mail. E-mail over the Internet will handle courses which require only the basic ASCII character set. Many courses can be handled this way, but students should inquire about electronic options available for particular courses. The e-mail address for those questions is independ@ext.missouri.edu. The URL is http://indepstudy .ext.missouri.edu/.

Exams can be requested by e-mail, but must be sent via U.S. Postal Service to an approved examination site where they can be proctored and returned to the Center for grading.

Incidentally, the student in Germany finished his course in technical writing in good time: He used ftp to send fully formatted papers to his professor via the Center, and comments were returned to him the same way or by e-mail. He was very pleased at the speed it permitted and the savings in postage and mailing expense. We have also had several professors who were writing courses while they were in Europe sending their manuscripts back and forth via the Internet.

Dale Huffington

University of Missouri

Columbia, Missouri

http://www.missouri.edu/~dldcwww/

Generating Sequential Keys

Dear DDJ,

The December 1995 "Algorithm Alley" column by Gene Callahan entitled "Generating Sequential Keys in an Arbitrary Radix" reminded me of a problem posed in an introductory Pascal course several years ago: The state needs to issue license plates; provide a function which, given a license number "AAZ 999" (for a complex example), returns the next in sequence, "ABA 000." A student in the course worked for a client of mine; I provided a solution (with the explicit design goal that the program could in no way be regarded as the output of a first-year student) that used the (VAX) Pascal schema construct to make a numeric string. The arguments to the schema definition were a set of legal characters and a string length.

The increment() operation on this schema returned not only the incremented string, but a carry flag to indicate overflow (as when "999" was wrapped to "000"). Thus, the LicensePlate type contained two NumericStrings of length 3, one based on the set ('A'..'Z'), the other on the set ('0'..'9'). The nextPlate() operation would increment the numeric string, and then--on a carry out of this operation--increment the alphabetic string.

I'm sure the program met its design goal: The student didn't dare turn it in as her own work. I wonder now how I would solve the problem, had it been required for a C or C++ class. The capabilities of the language shape the design, certainly: I'd probably have several hundred lines of C++ code implementing OrderedSet<char>, NumericString<OrderedSet<char>, and so forth.

Ron Lusk

Blue Bell, Pennsylvania

ron.lusk@phh.mts.dec.com

Never Mind the Bullocks...

Dear DDJ,

Regrettably, bassists may die, but their estates live on. By simply naming his music program "Mingus'' or "Pastorius,'' Al Stevens is getting no guarantee of safety. (See "C Programming,'' DDJ, September 1995.) Fortunately, there is one name meeting your criteria which should be free of any such concerns, with the added bonus of suitably reflecting the likely quality of the output during the inevitable debugging stages--Vicious.

Mike Ryan

Virtuoso Software

http://world.std.com/~deeryan/virtuoso.html

Mac Can Do

Dear DDJ,

I enjoyed the article "Networking Objects with CORBA," by Mark Betz (DDJ, November 1995). However, Mark's statement about major operating-system vendors' support of TCP/IP was incomplete. He did not mention that the Macintosh operating system has had a solid TCP/IP stack for years and that it has been included with OS releases since last year (System 7.5).

Justin Souter

Justin_Souter@artlogic.com

Mark replies: Thanks Justin, that's a very good point. I admit that I simply failed to consider the Macintosh when I made the statement. We do have Macs where I work, and they are on our TCP/IP domain along with everything else.

Go Figure

Dear DDJ,

Thanks for publishing the article "Data Models, CASE Tools, and Client/Server Development,'' by Tim Wittenburg (DDJ, November 1995). However, it appears that the illustrations for Figure 1 and Figure 2 on page 92 were reversed.

Jim Rommens

tktfa31%ezmail@pyibm1.cc.bellcore.com

Table 1: Prime time again.

Sequence Number    Prime Number

       1                 2

       2                 3

       3                 5

       4                 7

       5                11

       6                13

       7                17

       8                19

       9                23

      10                29

      11                31

      12                37

      13                41

      14                43

      15                47

      16                53

      17                59

      18                61

      19                67

      20                71

Example 1: Ada 95 classes.

type Object is tagged record
     Pos : Position;
end record;
type Line is new Object with
                       record
     Offset : Size;
end record;