Lisp HUG Maillist Archive

dspec can't find source with define-condition alias?

Hi all,

Say I've got the following code in file, dspec-bug.lisp:

=====================================================
(defmacro defcondition (&rest args)
  `(define-condition ,@args))

(dspec:define-form-parser (defcondition (:alias define-condition)))

(defmacro deffunction (&rest args)
  `(defun ,@args))

(dspec:define-form-parser (deffunction (:alias defun)))

(defcondition some-condition () ())

(deffunction some-function ())
=====================================================

After compiling and loading, trying to find the source of
some-function works, but finding the source of some-condition does not
(though the correct file, dspec-bug.lisp, is known. I'm on LWM 5.1.2
(PPC). You can see the behavior at:

http://www.cs.rpi.edu/~tayloj/DOCS/dspec-bug.mov

Is find source not supported for conditions, or is this a bug (in
which case I'll file a bug report).

Thanks,

-- 
=====================
Joshua Taylor
tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu

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


Re: dspec can't find source with define-condition alias?

On Sat, Mar 7, 2009 at 4:21 PM, Joshua TAYLOR <tayloj@cs.rpi.edu> wrote:
> Hi all,
>
> Say I've got the following code in file, dspec-bug.lisp:
>
> =====================================================
> (defmacro defcondition (&rest args)
>  `(define-condition ,@args))
>
> (dspec:define-form-parser (defcondition (:alias define-condition)))
>
> (defmacro deffunction (&rest args)
>  `(defun ,@args))
>
> (dspec:define-form-parser (deffunction (:alias defun)))
>
> (defcondition some-condition () ())
>
> (deffunction some-function ())
> =====================================================
>
> After compiling and loading, trying to find the source of
> some-function works, but finding the source of some-condition does not
> (though the correct file, dspec-bug.lisp, is known. I'm on LWM 5.1.2
> (PPC). You can see the behavior at:
>
> http://www.cs.rpi.edu/~tayloj/DOCS/dspec-bug.mov
>
> Is find source not supported for conditions, or is this a bug (in
> which case I'll file a bug report).
>
> Thanks,
>
> --
> =====================
> Joshua Taylor
> tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu
>
> "A lot of good things went down one time,
>  back in the goodle days."
>    John Hartford
>


As a little bit of followup, I noticed now that the doc for
DEFINE-FORM-PARSER [1] has:

"LispWorks contains pre-defined form parser functions for the Common
Lisp definers defun , defmethod , defgeneric , defvar , defparameter ,
defconstant , defstruct , defclass , defmacro  and deftype  and for
LispWorks definers such as fli:define-foreign-type  and
dspec:define-form-parser  itself."

So I guess define-condition isn't one of the supported ones. (It would
be nice if it were.) That in mind, the next logical choice for an
alias for defcondition would be, it would seem to me, defclass. But
defclass aliases don't seem to work either (and the following code
demonstrates it).

==============================================
;;; Functions

(defmacro define-function (&rest args)
  `(defun ,@args))

(dspec:define-form-parser (define-function (:alias defun)))

(defun function1 ())
(define-function function2 ())

;; function1      <= find source works
;; function2      <= find source works

;;; Conditions

(defmacro defcondition (&rest args)
  `(define-condition ,@args))

(dspec:define-form-parser (defcondition (:alias defclass)))

(define-condition condition1 () ())
(defcondition condition2 () ())

;; condition1    <= find source works
;; condition2    <= find source doesn't work

;;; Classes

(defmacro define-class (&rest args)
  `(defclass ,@args))

(dspec:define-form-parser (define-class (:alias defclass)))

(defclass class1 () ())
(define-class class2 () ())

;; class1     <= find source works
;; class2     <= find source doesn't work
==============================================

Thanks in advance,
//JT

[1] http://www.lispworks.com/documentation/lw51/LWRM/html/lwref-135.htm

-- 
=====================
Joshua Taylor
tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu

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


Re: dspec can't find source with define-condition alias?

On Mon, Mar 9, 2009 at 2:38 PM, Martin Simmons <martin@lispworks.com> wrote:
>>>>>> On Sat, 7 Mar 2009 16:44:12 -0500, Joshua TAYLOR said:
>>
>> On Sat, Mar 7, 2009 at 4:21 PM, Joshua TAYLOR <tayloj@cs.rpi.edu> wrote:
>> > Hi all,
>> >
>> > Say I've got the following code in file, dspec-bug.lisp:
>> >
>> > =====================================================
>> > (defmacro defcondition (&rest args)
>> >  `(define-condition ,@args))
>> >
>> > (dspec:define-form-parser (defcondition (:alias define-condition)))
>> >
>> > (defmacro deffunction (&rest args)
>> >  `(defun ,@args))
>> >
>> > (dspec:define-form-parser (deffunction (:alias defun)))
>> >
>> > (defcondition some-condition () ())
>> >
>> > (deffunction some-function ())
>> > =====================================================
>> >
>> > After compiling and loading, trying to find the source of
>> > some-function works, but finding the source of some-condition does not
>> > (though the correct file, dspec-bug.lisp, is known. I'm on LWM 5.1.2
>> > (PPC). You can see the behavior at:
>> >
>> > http://www.cs.rpi.edu/~tayloj/DOCS/dspec-bug.mov
>> >
>> > Is find source not supported for conditions, or is this a bug (in
>> > which case I'll file a bug report).
>> >
>> > Thanks,
>> >
>> > --
>> > =====================
>> > Joshua Taylor
>>
>> As a little bit of followup, I noticed now that the doc for
>> DEFINE-FORM-PARSER [1] has:
>>
>> "LispWorks contains pre-defined form parser functions for the Common
>> Lisp definers defun , defmethod , defgeneric , defvar , defparameter ,
>> defconstant , defstruct , defclass , defmacro  and deftype  and for
>> LispWorks definers such as fli:define-foreign-type  and
>> dspec:define-form-parser  itself."
>>
>> So I guess define-condition isn't one of the supported ones. (It would
>> be nice if it were.) That in mind, the next logical choice for an
>> alias for defcondition would be, it would seem to me, defclass. But
>> defclass aliases don't seem to work either (and the following code
>> demonstrates it).
>
> It is OK to use (:alias define-condition) as a form parser.
>
> To fix the problem, you need to add an alias dspec:
>
> (dspec:define-dspec-alias defcondition (name)
>  `(define-condition ,name))
>
> Without that, it won't know that (defcondition some-condition) is the same as
> (define-condition some-condition), which is the dspec recorded when the
> define-condition macro is evaluated.
>
> --
> Martin Simmons
> LispWorks Ltd
> http://www.lispworks.com/

Is there a particular reason that things /do/ work with the function
example? Is that a behavior that I shouldn't depend on? (I.e., In
terms of the example I used above, ought I be doing
(dspec:define-dspec-alias deffunction …) as well?)

Thanks,
-- 
=====================
Joshua Taylor
tayloj@cs.rpi.edu, jtaylor@alum.rpi.edu


Re: dspec can't find source with define-condition alias?

>>>>> On Mon, 9 Mar 2009 16:25:09 -0400, Joshua TAYLOR said:
> 
> On Mon, Mar 9, 2009 at 2:38 PM, Martin Simmons <martin@lispworks.com> wrote:
> >>>>>> On Sat, 7 Mar 2009 16:44:12 -0500, Joshua TAYLOR said:
> >>
> >> On Sat, Mar 7, 2009 at 4:21 PM, Joshua TAYLOR <tayloj@cs.rpi.edu> wrote:
> >> > Hi all,
> >> >
> >> > Say I've got the following code in file, dspec-bug.lisp:
> >> >
> >> > =====================================================
> >> > (defmacro defcondition (&rest args)
> >> >  `(define-condition ,@args))
> >> >
> >> > (dspec:define-form-parser (defcondition (:alias define-condition)))
> >> >
> >> > (defmacro deffunction (&rest args)
> >> >  `(defun ,@args))
> >> >
> >> > (dspec:define-form-parser (deffunction (:alias defun)))
> >> >
> >> > (defcondition some-condition () ())
> >> >
> >> > (deffunction some-function ())
> >> > =====================================================
> >> >
> >> > After compiling and loading, trying to find the source of
> >> > some-function works, but finding the source of some-condition does not
> >> > (though the correct file, dspec-bug.lisp, is known. I'm on LWM 5.1..2
> >> > (PPC). You can see the behavior at:
> >> >
> >> > http://www.cs.rpi.edu/~tayloj/DOCS/dspec-bug.mov
> >> >
> >> > Is find source not supported for conditions, or is this a bug (in
> >> > which case I'll file a bug report).
> >> >
> >> > Thanks,
> >> >
> >> > --
> >> > =====================
> >> > Joshua Taylor
> >>
> >> As a little bit of followup, I noticed now that the doc for
> >> DEFINE-FORM-PARSER [1] has:
> >>
> >> "LispWorks contains pre-defined form parser functions for the Common
> >> Lisp definers defun , defmethod , defgeneric , defvar , defparameter ,
> >> defconstant , defstruct , defclass , defmacro  and deftype  and for
> >> LispWorks definers such as fli:define-foreign-type  and
> >> dspec:define-form-parser  itself."
> >>
> >> So I guess define-condition isn't one of the supported ones. (It would
> >> be nice if it were.) That in mind, the next logical choice for an
> >> alias for defcondition would be, it would seem to me, defclass. But
> >> defclass aliases don't seem to work either (and the following code
> >> demonstrates it).
> >
> > It is OK to use (:alias define-condition) as a form parser.
> >
> > To fix the problem, you need to add an alias dspec:
> >
> > (dspec:define-dspec-alias defcondition (name)
> >  `(define-condition ,name))
> >
> > Without that, it won't know that (defcondition some-condition) is the same as
> > (define-condition some-condition), which is the dspec recorded when the
> > define-condition macro is evaluated.
> >
> > --
> > Martin Simmons
> > LispWorks Ltd
> > http://www.lispworks.com/
> 
> Is there a particular reason that things /do/ work with the function
> example? Is that a behavior that I shouldn't depend on? (I.e., In
> terms of the example I used above, ought I be doing
> (dspec:define-dspec-alias deffunction …) as well?)

It works for functions because the form parser for defun returns the function
name some-condition rather than the full dspec list (defun some-condition).
Normally a form parser returns a dspec containing the defining macro's name,
which makes them non-equal for different defining forms unless a dspec alias
is defined.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/


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