[Ecls-list] Broken dispatching macro characters

Adam Warner lists at consulting.net.nz
Sat Apr 16 23:50:30 UTC 2005

Hi all,

I believe this code should compile:

(eval-when (:compile-toplevel :load-toplevel :execute)
  (defconstant |FALSE| '|FALSE|)
   #\# #\f
   (lambda (stream sub-char n)
     (declare (ignore stream sub-char n))

(eval-when (:compile-toplevel :load-toplevel :execute)
  (export '|false|)
  (declaim (inline |false|))
  (defun |false| (arg)
    (eq arg #f)))

In ECL this occurs:

No dispatch function defined for character #\f.
Broken at LOAD.

It turns out that only #F is defined, not #f.

SET-DISPATCH-MACRO-CHARACTER specifies that "If sub-char is a lowercase
letter, it is converted to its uppercase equivalent." So you're right in
defining #F.

2.4.8 Sharpsign states: "The standard syntax includes constructs
introduced by the # character. The syntax of these constructs is as
follows: a character that identifies the type of construct is followed by
arguments in some form. If the character is a letter, its case is not
important; #O and #o are considered to be equivalent, for example."

Because the specification provides no way to dispatch on a lowercase
sub-char distinct from an uppercase sub-char it seems reasonable that
lowercase sub-chars are converted to their uppercase equivalent. Other
implementations do this.

Note that non-dispatching macro characters are distinguished by case.

A better specification would leave the case of sub-char alone in
SET-DISPATCH-MACRO-CHARACTER and define duplicate definitions for
standard sharpsign syntax, i.e. #O and #o would be equivalent because
distinct sub-chars O and o would invoke the same reader function.


More information about the ecl-devel mailing list