From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!newsfeed.belnet.be!news.belnet.be!news.brutele.be!nmaster.kpnqwest.net!nnum.kpnqwest.net!EU.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: using dispatch macro characters References: <3D19B3E4.AC474587@eurocom.od.ua> Mail-Copies-To: never From: Erik Naggum Message-ID: <3234116820393808@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 42 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Date: Wed, 26 Jun 2002 21:47:00 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1025128020 193.71.199.50 (Wed, 26 Jun 2002 23:47:00 MET DST) NNTP-Posting-Date: Wed, 26 Jun 2002 23:47:00 MET DST Xref: archiver1.google.com comp.lang.lisp:35787 * Vladimir Zolotykh | Below is simple usage of dispatch macro character : | (defun |#!-reader| (stream char arg) | (declare (ignore char arg)) | (ecase (char-upcase (read-char stream t nil t)) | (#\K (* 1024 (read stream t nil t))) | (#\M (* 1024 1024 (read stream t nil t))) | (#\G (* 1024 1024 1024 (read stream t nil t))))) Please take a look at what this "arg" you ignore really is and how the reader already provides a value that you might find particularly useful. _Please_ note that this is a bad use of a case-insensitive characters. E.g., light travels at approximately 300 Mm/s, which is _way_ faster than 300 mm/s, which is about the speed at which my randomly waving hand usually hits the light switch in the morning. On the even lighter side, some broadband company over here recently advertised 2 mbps residential rate. At last, some truth in Internet advertising! At any rate, it would have been better to use ((#\k #\K) ...) than to call char-upcase. Please also note that "k" is the ISO prefix for 1000, "K" is not, but has been used for 1024. "M" is 1,000,000, "G" is 1,000,000,000, "m" is 1/1000. An enterprising brainslug has suggested that to solve this non-problem, we should write 1 kiB for 1024 bytes, 2 MiB for the recently released sequel, and 4 GiB for what was previously just known as 2³². Some Linux freaks have not seen through this stunt and so the Linux kernel and many GNU utilities use this silliness. I would much have preferred a notation like 1B3, like 1E3, such that in 1Bn, n equal to 3/10 of base 2 logarithm of the exponent. Of course, this might be confusing to some people who are unfamiliar with the common "engineering notation" that underlies the ISO prefix system to begin with (but such people should be ignored, anyway). In any case, I bet it looks less unfamiliar than this horrible XiB notation. (Nobody would use it for anything other than "binary amounts", anyway, and that is just "nerdy" enough that an engineering-based notation should be acceptable.) -- Guide to non-spammers: If you want to send me a business proposal, please be specific and do not put "business proposal" in the Subject header. If it is urgent, do not use the word "urgent". If you need an immediate answer, give me a reason, do not shout "for your immediate attention". Thank you.