Lisp HUG Maillist Archive

intern / apply / &rest / defmacro badness...

Hi all,
I've reduced a problem I was having to the following code.


(defmacro deffunction1 (bar)
  `(defun ,(intern (concatenate 'string (symbol-name bar))) ()
     34))

(deffunction1 a)
(deffunction1 b)

(defmacro deffunction2 (bar)
  (labels ((c  (&rest args) (apply #'concatenate 'string args))
           (ci (&rest args) (intern (apply #'c args))))
    `(defun ,(ci (symbol-name bar)) ()
       34)))

(deffunction2 c)
(deffunction2 d)


I've got this in a file open in the Editor and I press
File->Compile and Load, and I see the following:


;;; Compiling file /Users/tayloj/dtopthings/foo.lisp ...
;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 0
;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
;;; Source level debugging is on
;;; Source file recording is  on
;;; Cross referencing is on
; (Top-Level-Form 1)
; Deffunction1
; A
; B
; Deffunction2
; ||
; ||
; (Top-Level-Form 2)
; Loading fasl file /Users/tayloj/dtopthings/foo.nfasl
Warning: || defined more than once in /Users/tayloj/dtopthings/foo.lisp.


Clearly I'm not getting the symbols that I need in place at the defun.
I've tried
various permutations of the apply and the &rest arglists, but I can't seem to
get the bug in a smaller chunk of code. Some other LISPs don't choke on this
so I'm not inclined to think I'm doing something bad, but rather that there's
something nasty going on in the &rest args and the applying.

I'm using LWM (Academic)  5.0.

Thanks in advance!

-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


Re: intern / apply / &rest / defmacro badness...

Sorry to reply to my own message, but I was wondering if it can be
confirmed that this is a compiler bug (which Chris' reply seems to
illustrate) and whether there's some workaround, or general advice of
what /not/ to do. It's easy to avoid in the particular instance that
I've got, but it'd be nice to know /what/ to avoid.

Thanks in advance!

On 3/9/07, Taylor, Joshua <tayloj@rpi.edu> wrote:
> Hi all,
> I've reduced a problem I was having to the following code.
>
>
> (defmacro deffunction1 (bar)
>   `(defun ,(intern (concatenate 'string (symbol-name bar))) ()
>      34))
>
> (deffunction1 a)
> (deffunction1 b)
>
> (defmacro deffunction2 (bar)
>   (labels ((c  (&rest args) (apply #'concatenate 'string args))
>            (ci (&rest args) (intern (apply #'c args))))
>     `(defun ,(ci (symbol-name bar)) ()
>        34)))
>
> (deffunction2 c)
> (deffunction2 d)
>
>
> I've got this in a file open in the Editor and I press
> File->Compile and Load, and I see the following:
>
>
> ;;; Compiling file /Users/tayloj/dtopthings/foo.lisp ...
> ;;; Safety = 3, Speed = 1, Space = 1, Float = 1, Interruptible = 0
> ;;; Compilation speed = 1, Debug = 2, Fixnum safety = 3
> ;;; Source level debugging is on
> ;;; Source file recording is  on
> ;;; Cross referencing is on
> ; (Top-Level-Form 1)
> ; Deffunction1
> ; A
> ; B
> ; Deffunction2
> ; ||
> ; ||
> ; (Top-Level-Form 2)
> ; Loading fasl file /Users/tayloj/dtopthings/foo.nfasl
> Warning: || defined more than once in /Users/tayloj/dtopthings/foo.lisp.
>
>
> Clearly I'm not getting the symbols that I need in place at the defun.
> I've tried
> various permutations of the apply and the &rest arglists, but I can't seem to
> get the bug in a smaller chunk of code. Some other LISPs don't choke on this
> so I'm not inclined to think I'm doing something bad, but rather that there's
> something nasty going on in the &rest args and the applying.
>
> I'm using LWM (Academic)  5.0.
>
> Thanks in advance!
>
> --
> =====================
> Joshua Taylor
> tayloj@rpi.edu
>
> "A lot of good things went down one time,
>      back in the goodle days."
>                John Hartford
>


-- 
=====================
Joshua Taylor
tayloj@rpi.edu

"A lot of good things went down one time,
     back in the goodle days."
               John Hartford


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