[Openmcl-devel] Annoying, Deprecated #\, Macros
Gary Byers
gb at clozure.com
Sun Oct 8 22:55:05 PDT 2006
When the reader encounters a false conditional (like #+maclisp, unless
you're actually running on a PDP-10, in which case: do you want to sell
it ?), it binds *READ-SUPPRESS* to T and reads the following expression
(ignoring the result and suppressing some read-time side-effects and
inhibiting some read-time behavior.) In order to read the expression,
it has to invoke the functions associated with dispatching macros so
that it can (properly) skip over the tokens/forms that those macros
would consume. As a silly example:
#+use-literal-arrays #(nil nil nil) #-use-literal-arrays (make-array 3
:initial-element nil)
If :USE-CONSTANT-ARRAYS isn't on *FEATURES*, the reader still has to
invoke the #( macro in order to know to skip over the form following
the false conditonal.
This basically works fine as long as the next form can be constructed from
standard reader macros, but it means that you can't use #+/#- to
"hide" non-standard reader macros. (A similar issue arises with
OpenMCL's FFI-related reader macros; an implementation that doesn't
understand #_ or #$ has no way of knowing whether they "read the next
token with *readtable-case* set to :preserve, intern the resulting
token in some OS-dependent-package, and give the resulting symbol
FFI-related macro or constant definitions" or "treat everything up to
the next newline as whitespace" or practically anything else, and it
would need to know this in order to be able to "skip over" (read with
*READ-SUPPRESS* in effect) the tokens which follow the #_/#$ ...)
Most (probably all, I can't think of an exception) uses of #, in
legacy code can be replaced with LOAD-TIME-VALUE, as in:
(defun gen-name ( &optional k &aux (n (load-time-value (*array nil 'fixnum 1))))
;; I hope that's right.
...)
I think that that observation was what led to the demise of #, all those
years ago. LOAD-TIME-VALUE's behavior is better-defined than #,'s was,
but the cases where either is necessary and the issues related to why
LOAD-TIME-VALUE is "better" are all pretty obscure.
On Sun, 8 Oct 2006, Brent Fulgham wrote:
> Some time ago (http://www.clozure.com/pipermail/openmcl-devel/2005-
> November/003085.html), Gary discussed the rationale behind removing
> the "#," macro. This weekend, in trying to get Maxima to build under
> OpenMCL 1.0, I ran into the following form, which fails to read:
>
> (from Maxima's "src/transq.lisp" file):
> #+maclisp
> (defun gen-name ( &optional k &aux (n '#,(*array nil 'fixnum 1)))
> (store (arraycall fixnum n 0) (f1+ (arraycall fixnum n 0)))
> (and k (store (arraycall fixnum n 0) k))
> (implode (append (exploden *infile-name-key*)
> (exploden '|-tr-gen-|)
> (exploden (arraycall fixnum n 0)))))
>
> I tried various forms of:
>
> #+(and :maclisp (not :openmcl))
>
> and
>
> #-openmcl
>
> and eventually just commented the thing out.
>
> While this function is not needed for Maxima, it seems odd that I
> can't get OpenMCL to ignore the function entirely so that the sources
> can retain their cross-lisp system compatibility. Any idea what I'm
> doing wrong?
>
> Thanks,
>
> -Brent
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/mailman/listinfo/openmcl-devel
>
>
More information about the Openmcl-devel
mailing list