Subject: Re: using  dispatch macro characters
From: Erik Naggum <erik@naggum.net>
Date: Wed, 26 Jun 2002 21:47:00 GMT
Newsgroups: comp.lang.lisp
Message-ID: <3234116820393808@naggum.net>

* 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.