Ticket #665 (closed defect: invalid)
Setting a reader macro for a constituent breaks objc method syntax
| Reported by: | rongarret | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Objective-C Bridge | Version: | trunk |
| Keywords: | Cc: |
Description
SLSIA. Here's an example:
Welcome to Clozure Common Lisp Version 1.5-dev-r13442M-trunk (DarwinX8664)! ? (#/title (car (gui::windows))) #<NS-MUTABLE-STRING "Listener" (#x1D03B0)> ? (set-macro-character #\e (lambda (stream char) char) t) ;Compiler warnings : ; In an anonymous lambda form at position 25: Unused lexical variable STREAM T ? (#/title (car (gui::windows))) > Error: Undefined function NEXTSTEP-FUNCTIONS:|titl| called with arguments (#\e #<HEMLOCK-LISTENER-FRAME <HemlockListenerFrame: 0x1cd640> (#x1CD640)>) .
Here's the fix:
(set-dispatch-macro-character #\# #\/
(let ((rt (copy-readtable nil)))
(lambda (stream subchar numarg)
(declare (ignorable subchar numarg))
(let* ((token (make-array 16 :element-type 'character :fill-pointer 0 :adjustable t))
(attrtab (rdtab.ttab rt)))
(when (peek-char t stream nil nil)
(loop
(multiple-value-bind (char attr)
(%next-char-and-attr stream attrtab)
(unless (eql attr $cht_cnst)
(when char (unread-char char stream))
(return))
(vector-push-extend char token))))
(unless *read-suppress*
(unless (> (length token) 0)
(signal-reader-error stream "Invalid token after #/."))
(check-objc-message-name token)
(intern token "NSFUN"))))))
NOTE: This issue is related to the issue of reader macros affecting the syntax of uninterned symbols, which generate some controversy on the mailing list. In this case, the syntax of objective-C function names is not governed by the ANSI standard, so the controversy is moot.
Change History
Note: See
TracTickets for help on using
tickets.
