Date: Fri, 09 Feb 2001 08:46:56 +0100 From: Poul-Henning Kamp <phk@critter.freebsd.dk> To: Luigi Rizzo <luigi@info.iet.unipi.it> Cc: Bruce Evans <bde@zeta.org.au>, Peter Wemm <peter@netplex.com.au>, Mark Murray <mark@grondar.za>, Mike Heffner <mikeh@FreeBSD.org>, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: QUEUE macros considered harmful (was Re: cvs commit: src/usr.bin/lam lam.c) Message-ID: <20580.981704816@critter> In-Reply-To: Your message of "Fri, 09 Feb 2001 08:35:35 %2B0100." <200102090735.IAA31362@info.iet.unipi.it>
next in thread | previous in thread | raw e-mail | index | archive | help
> 15 macros for [doubly-linked ?] circular queues (CIRCLEQ) No longer there. >and apart from the number of them, the interface is not always >obvious, the manpage is not consistent, and the way they are used >is worth a prize at the Obfuscated Programming contest. Some of the code I have converted to use macros were infinitely more obfuscated before. >Simple example taken from the firewall code: As you say "Simple example". Most people can write a correctly structured "make world" program. Try with an example from some more complicated code. And if you don't want to use <sys/queue.h> in your code then don't. I have been advocating changing the users of <sys/queue.h> to not grope around inside the structures in all kinds of bogus and non-bogus manners. Introduction of <sys/queue.h> in code is a different story. I don't advocate that <sys/queue.h> is the best thing since sliced bread, but it is the best that we currently have. >I can admit that there are some cases where a (limited) use >of such macros can simplify life and reduce the chance of errors, >but my feeling is that we are really abusing these macros. I belive in data-hiding. If our chosen language had supported it, the queues wouldn't have been macros. For now I belive that if we have <sys/queue.h> we should hide the implementation details of it so that it can be improved later without having to revisit the code again and again. I will also strike a blow for the people who are not in a position to say that nobody in the world know more about UFS than they do: It is important that our code doesn't require you to be a world class programmer to be able to read it. Many of our new "staff" are new to computers and programming. I certainly don't subscribe to "If it looks complicated it shows how great a programmer I am". >but 'TYPE' is not really a type, (the real type 'struct TYPE'), I have advocated fixing this bogosity earlier, but was shouted down by the "compatible with UNIX 1st edition at all costs" contingent. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20580.981704816>