Lisp HUG Maillist Archive

compiler error involving #+ and an undefined reader macro, #_

Trying to compile the local-time library, available at
common-lisp.net.  It has this function definition, which gets an error
at the #_gettimeofday:

  (defun %unix-gettimeofday ()
    "Cross-implementation gettimeofday abstraction"
    #+cmu
    (unix:unix-gettimeofday)
    #+sbcl
    (sb-unix:unix-gettimeofday)
    #+ccl
    (ccl::rlet ((tv :timeval))
      (#_gettimeofday tv (ccl::%null-ptr)) ;; <=== ERROR on #_
      (values t (ccl::pref tv :timeval.tv_sec) (ccl::pref tv :timeval.tv_usec)))
    #-(or cmu sbcl ccl)
    (values t (get-universal-time) 0))

:ccl is not in *FEATURES*.

I got around it by 

  #-ccl
  (set-dispatch-macro-character #\# #\_ (constantly nil))

which seems to work.  (On the other hand, I'm not terribly familiar
with reader macros, so this may've been, uh, sub-optimal.  :)

My question is, why does LW try to process the reader macro at all,
since it's protected (if that's the right word) by #+ccl?

-- Larry


Re: compiler error involving #+ and an undefined reader macro, #_

Unable to parse email body. Email id is 9068

Re: compiler error involving #+ and an undefined reader macro, #_

Larry Clapp <larry@theclapp.org> writes:

> I patched my LOCAL-TIME's ASDF file (and submitted it to their devel
> mailing list):
>
>     #+lispworks
>     (defmethod perform :around ((op compile-op) c)
>       ;; Make %unix-gettimeofday compile under Lispworks, which doesn't ignore the
>       ;; #_ reader macro in #_gettimeofday.
>       (let ((*readtable* (copy-readtable)))
> 	(set-dispatch-macro-character #\# #\_ (constantly nil))
> 	(call-next-method)))

On CCL, #_ presumably has an equivalent non-read syntax. I think the
upstream package should just use that.

  -T.


Re: compiler error involving #+ and an undefined reader macro, #_

Larry Clapp <larry@theclapp.org> writes:

> I don't understand what you mean.  Do you want the LOCAL-TIME library
> to copy CCL's #_ read macro for every other implementation?  That
> would be both non-trivial and pointless.  (See
> http://ccl.clozure.com/ccl-documentation.html#The-Interface-Database).

No I mean instead of using the syntax it should use whatever the syntax
expands to. E.g. instead of 'foo it should use (QUOTE FOO). From
glancing at the documentation, (#_foo ...) is equivalent to
(EXTERNAL-CALL "foo" ...)  or something similiar.

  -T.


Re: compiler error involving #+ and an undefined reader macro, #_

Tim Bradshaw <tfb@cley.com> writes:

> On 24 Mar 2009, at 17:55, Larry Clapp wrote:
>
>> Since (in LW) reader macros are called even in a #+/#-, the issue
>> isn't what the macro does, it's that it's undefined, so LW signals a
>> READER-ERROR.  If we define it (even if it does nothing, as in my
>> patch), then everybody's happy.
>
> Well, everyone who doesn't already have a reader macro defined which
> does something different.  Read macros are horribly global things.

Actually they're not so horrible. Not more than packages that
is.[*] 

What makes them horrible is that readtables are too opaque.

See http://common-lisp.net/~trittweiler/with-readtable-iterator.pdf for
a start. (I've got to fundamentally revise it before publishing which I
haven't done due to lack of time.)

  -T.

[*] COMPILE-FILE and LOAD are required to bind *READTABLE* just like
    *PACKAGE*


Updated at: 2020-12-10 08:41 UTC