From: Jeronimo Pellegrini
Subject: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <fnt53e$3b7$1@aioe.org>
Hi,

This:

defun z ()
  (labels ((a ()
              "aaa"
              (declare (optimize (speed 3) (safety 1)))
              (pprint 1)))
    (a)))

Works on all Lisps I have tried except XCL. Is it legal according to ANSI?

I mean, tit compiles nicely if there is no docstring before the DECLARE. But
with the docstring, XCL interprets (DECLARE ...) as a function call.

BTW, I tried sending email to Peter Graves, but it's bouncing.

J.

From: Rainer Joswig
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <joswig-D58D9F.20362231012008@news-europe.giganews.com>
In article <············@aioe.org>,
 Jeronimo Pellegrini <···@aleph0.info> wrote:

> Hi,
> 
> This:
> 
> defun z ()
>   (labels ((a ()
>               "aaa"
>               (declare (optimize (speed 3) (safety 1)))
>               (pprint 1)))
>     (a)))
> 
> Works on all Lisps I have tried except XCL. Is it legal according to ANSI?
> 
> I mean, tit compiles nicely if there is no docstring before the DECLARE. But
> with the docstring, XCL interprets (DECLARE ...) as a function call.
> 
> BTW, I tried sending email to Peter Graves, but it's bouncing.
> 
> J.

You can answer those questions by looking at the CLHS.

Here is a symbol index:

http://www.lispworks.com/documentation/HyperSpec/Front/X_Symbol.htm

LABELS is here:

http://www.lispworks.com/documentation/HyperSpec/Body/s_flet_.htm#labels

The syntax for LABELS is:

  labels ((function-name lambda-list [[local-declaration* | local-documentation]] local-form*)*) declaration* form*

This means that at most one local-documentation,
and any number of local-declarations can occur in any order. 


The EBNF notation is described here:

http://www.lispworks.com/documentation/HyperSpec/Body/01_dab.htm
From: Jeronimo Pellegrini
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <fo4bhj$4uv$1@aioe.org>
On 2008-01-31, Rainer Joswig <······@lisp.de> wrote:
> You can answer those questions by looking at the CLHS.
>
> Here is a symbol index:
>
> http://www.lispworks.com/documentation/HyperSpec/Front/X_Symbol.htm
>
> LABELS is here:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/s_flet_.htm#labels
>
> The syntax for LABELS is:
>
>   labels ((function-name lambda-list [[local-declaration* | local-documentation]] local-form*)*) declaration* form*
>
> This means that at most one local-documentation,
> and any number of local-declarations can occur in any order. 
>
>
> The EBNF notation is described here:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/01_dab.htm

Thanks Rainer and everyone else who replied!
So it's a bug in XCL...

J.
From: Pascal Bourguignon
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <878x25rd4z.fsf@thalassa.informatimago.com>
Jeronimo Pellegrini <···@aleph0.info> writes:

> Hi,
>
> This:
>
> defun z ()
>   (labels ((a ()
>               "aaa"
>               (declare (optimize (speed 3) (safety 1)))
>               (pprint 1)))
>     (a)))
>
> Works on all Lisps I have tried except XCL. Is it legal according to ANSI?
>
> I mean, tit compiles nicely if there is no docstring before the DECLARE. But
> with the docstring, XCL interprets (DECLARE ...) as a function call.


This is a bug in XCL.  local-documentation and local-declaration can
be written in any order (this is what is meant by [[ and ]]).
See: http://www.lispworks.com/documentation/HyperSpec/Body/01_daba.htm

CLHS:
    labels ((function-name lambda-list [[local-declaration* | local-documentation]]
    local-form*)*) declaration* form*


(declare ...)
"doc"
(declare ...)

"doc"
(declare ...)
(declare ...)

(declare ...)
(declare ...)
"doc"

etc...



-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Cats meow out of angst
"Thumbs! If only we had thumbs!
We could break so much!"
From: Joshua Taylor
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <d11a73d7-26e2-44aa-821a-5b0da1258556@i29g2000prf.googlegroups.com>
> CLHS:
>     labels ((function-name lambda-list [[local-declaration* | local-documentation]]
>     local-form*)*) declaration* form*
>
> (declare ...)
> "doc"
> (declare ...)
>
> "doc"
> (declare ...)
> (declare ...)
>
> (declare ...)
> (declare ...)
> "doc"
>
> etc...
>
> --
> __Pascal Bourguignon__                    http://www.informatimago.com/

This seems a relevant (at least partially) thread for a question I
have from time to time:

Is there an easy way to grab the docstring and declarations from a
list of forms, e.g., something from &body. This comes up from time to
time in macro writing. Is there a standard way of doing this? I
haven't found any CL facility, but neither would it be the first time
that I've missed something.

//J
From: alien_guy
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <fntkpf$roc$1@aioe.org>
On Thu, 31 Jan 2008 14:41:17 -0800, Joshua Taylor wrote:
> This seems a relevant (at least partially) thread for a question I have
> from time to time:
> 
> Is there an easy way to grab the docstring and declarations from a list
> of forms, e.g., something from &body. This comes up from time to time in
> macro writing. Is there a standard way of doing this? I haven't found
> any CL facility, but neither would it be the first time that I've missed
> something.
> 
> //J

PARSE-BODY of Alexandria.
From: Pascal J. Bourguignon
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <7c7iho3cj7.fsf@pbourguignon.anevia.com>
Joshua Taylor <···········@gmail.com> writes:

>> CLHS:
>>     labels ((function-name lambda-list [[local-declaration* | local-documentation]]
>>     local-form*)*) declaration* form*
>>
>> (declare ...)
>> "doc"
>> (declare ...)
>>
>> "doc"
>> (declare ...)
>> (declare ...)
>>
>> (declare ...)
>> (declare ...)
>> "doc"
>>
>> etc...
>>
>> --
>> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> This seems a relevant (at least partially) thread for a question I
> have from time to time:
>
> Is there an easy way to grab the docstring and declarations from a
> list of forms, e.g., something from &body. This comes up from time to
> time in macro writing. Is there a standard way of doing this? I
> haven't found any CL facility, but neither would it be the first time
> that I've missed something.

Yep. com.informatimago.common-lisp.source-form:extract-documentation,
extract-declarations, extract-body.

http://darcs.informatimago.com/lisp/common-lisp/source-form.lisp


-- 
__Pascal Bourguignon__
From: Joshua Taylor
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <d60c22f1-b779-4880-a673-2b05ccd7f0a9@y5g2000hsf.googlegroups.com>
On Feb 1, 10:46 am, ····@informatimago.com (Pascal J. Bourguignon)
wrote:
> Joshua Taylor <···········@gmail.com> writes:
> >> CLHS:
> >>     labels ((function-name lambda-list [[local-declaration* | local-documentation]]
> >>     local-form*)*) declaration* form*
>
> >> (declare ...)
> >> "doc"
> >> (declare ...)
>
> >> "doc"
> >> (declare ...)
> >> (declare ...)
>
> >> (declare ...)
> >> (declare ...)
> >> "doc"
>
> >> etc...
>
> >> --
> >> __Pascal Bourguignon__                    http://www.informatimago.com/
>
> > This seems a relevant (at least partially) thread for a question I
> > have from time to time:
>
> > Is there an easy way to grab the docstring and declarations from a
> > list of forms, e.g., something from &body. This comes up from time to
> > time in macro writing. Is there a standard way of doing this? I
> > haven't found any CL facility, but neither would it be the first time
> > that I've missed something.
>
> Yep. com.informatimago.common-lisp.source-form:extract-documentation,
> extract-declarations, extract-body.
>
> http://darcs.informatimago.com/lisp/common-lisp/source-form.lisp
>
> --
> __Pascal Bourguignon__

Ah, thanks Pascal, and also alien_guy. I knew there must be someone
out there that had packaged up this code.

//J
From: Juho Snellman
Subject: Re: Can I use a docstring followed by DECLARE in a local function?
Date: 
Message-ID: <873asd6aqh.fsf@vasara.proghammer.com>
Jeronimo Pellegrini <···@aleph0.info> writes:

> Hi,
> 
> This:
> 
> defun z ()
>   (labels ((a ()
>               "aaa"
>               (declare (optimize (speed 3) (safety 1)))
>               (pprint 1)))
>     (a)))
> 
> Works on all Lisps I have tried except XCL. Is it legal according to ANSI?

Yes, it's valid. See the CLHS page on LABELS for the exact syntax
description and CLHS 1.4.1.2.1 for a description of the notation.

-- 
Juho Snellman