From: Matt
Subject: Macros
Date: 
Message-ID: <a%nFf.12748$vU2.2195@newsread3.news.atl.earthlink.net>
Where are macros discussed in the HyperSpec?  I can't find it
for some reason.

Is the name of a macro a symbol?

How do I determine whether or not a symbol has been defined with
define-symbol-macro?

Thanks!
Matt

From: Peter Seibel
Subject: Re: Macros
Date: 
Message-ID: <m2k6c9am11.fsf@gigamonkeys.com>
Matt <·····@invalid.net> writes:

> Where are macros discussed in the HyperSpec?  I can't find it
> for some reason.

Chapter 3, Evaluation and Compilation

> Is the name of a macro a symbol?

Yes.

> How do I determine whether or not a symbol has been defined with
> define-symbol-macro?

Maybe something like this:

  (defun macro-symbol-p (symbol)
    (nth-value 1 (macroexpand symbol)))

-Peter

-- 
Peter Seibel           * ·····@gigamonkeys.com
Gigamonkeys Consulting * http://www.gigamonkeys.com/
Practical Common Lisp  * http://www.gigamonkeys.com/book/
From: Matt
Subject: Re: Macros
Date: 
Message-ID: <XToFf.6412$Nv2.4220@newsread1.news.atl.earthlink.net>
Peter Seibel wrote:
> Matt <·····@invalid.net> writes:

>> Is the name of a macro a symbol?
> 
> Yes.

Then why doesn't boundp return true for a defined symbol macro?
It says under boundp that it "determines only whether a symbol has
a value in the global environment", and under the section "3.1.1.1
The Global Enivironment" that the global environment contains
"bindings of macros/compiler macros", so I don't understand why
boundp won't tell me if a symbol is bound to a symbol macro or not.
Is a macro definition not considered a value?


>> How do I determine whether or not a symbol has been defined with
>> define-symbol-macro?
> 
> Maybe something like this:
> 
>   (defun macro-symbol-p (symbol)
>     (nth-value 1 (macroexpand symbol)))

Cool, that will work!  Thanks!
Matt
From: Bulent Murtezaoglu
Subject: Re: Macros
Date: 
Message-ID: <87psm1yfch.fsf@p4.internal>
>>>>> "M" == Matt  <·····@invalid.net> writes:
[...]
    M> Then why doesn't boundp return true for a defined symbol macro?
[...]
http://www.lispworks.com/documentation/HyperSpec/Body/f_fbound.htm

    M> ...  Is a macro definition not considered a
    M> value? ...

It is considered a value, but what you consider a value and what
boundp considers a value are different.  CL is (um, al least) a
Lisp-2, and while boundp looks at the 'value cell' fboundp looks at
the 'function cell.'  Also not that neither boundp nor fboundp will
detect lexical bindings.

cheers,

BM
From: Matt
Subject: Re: Macros
Date: 
Message-ID: <PopFf.6431$Nv2.3910@newsread1.news.atl.earthlink.net>
Bulent Murtezaoglu wrote:
>>>>>> "M" == Matt  <·····@invalid.net> writes:
> [...]
>     M> Then why doesn't boundp return true for a defined symbol macro?
> [...]
> http://www.lispworks.com/documentation/HyperSpec/Body/f_fbound.htm
> 
>     M> ...  Is a macro definition not considered a
>     M> value? ...
> 
> It is considered a value, but what you consider a value and what
> boundp considers a value are different.  CL is (um, al least) a
> Lisp-2, and while boundp looks at the 'value cell' fboundp looks at
> the 'function cell.'  Also not that neither boundp nor fboundp will
> detect lexical bindings.

I thought of that but fboundp always returns nada as well.

(define-symbol-macro foo "bar")
(fboundp 'foo)

Actually, I should be using (defconstant) now that I think about
what I'm trying to do.

Sorry, false alarm! :-)

Matt
From: Matt
Subject: Re: Macros
Date: 
Message-ID: <BspFf.6433$Nv2.1161@newsread1.news.atl.earthlink.net>
Matt wrote:

> I thought of that but fboundp always returns nada as well.
> 
> (define-symbol-macro foo "bar")
> (fboundp 'foo)
> 
> Actually, I should be using (defconstant) now that I think about
> what I'm trying to do.

Oh, no, I can't do that.  Nevermind.  Heh.
From: Bulent Murtezaoglu
Subject: Re: Macros
Date: 
Message-ID: <87lkwpydzy.fsf@p4.internal>
>>>>> "M" == Matt  <·····@invalid.net> writes:
[...]
    M> I thought of that but fboundp always returns nada as well.

    M> (define-symbol-macro foo "bar") (fboundp 'foo)

Oh, oops, sorry.  I misread your question as 'macro' not 'symbol macro.'
I think the others gave you good solutions.  

cheers,

B<more coffee>M 
From: Kenny Tilton
Subject: Re: Macros
Date: 
Message-ID: <mFpFf.311$Lp2.119@news-wrt-01.rdc-nyc.rr.com>
Peter Seibel wrote:
> Matt <·····@invalid.net> writes:
> 
> 
>>Where are macros discussed in the HyperSpec?  I can't find it
>>for some reason.
> 
> 
> Chapter 3, Evaluation and Compilation
> 
> 
>>Is the name of a macro a symbol?
> 
> 
> Yes.
> 
> 
>>How do I determine whether or not a symbol has been defined with
>>define-symbol-macro?
> 
> 
> Maybe something like this:
> 
>   (defun macro-symbol-p (symbol)
>     (nth-value 1 (macroexpand symbol)))

Can't we use macro-function?

ken
From: Pascal Bourguignon
Subject: Re: Macros
Date: 
Message-ID: <87hd7d7ocq.fsf@thalassa.informatimago.com>
Kenny Tilton <·············@nyc.rr.com> writes:

> Peter Seibel wrote:
>> Matt <·····@invalid.net> writes:
>> 
>>>Where are macros discussed in the HyperSpec?  I can't find it
>>>for some reason.
>> Chapter 3, Evaluation and Compilation
>> 
>>>Is the name of a macro a symbol?
>> Yes.
>> 
>>>How do I determine whether or not a symbol has been defined with
>>>define-symbol-macro?
>> Maybe something like this:
>>   (defun macro-symbol-p (symbol)
>>     (nth-value 1 (macroexpand symbol)))
>
> Can't we use macro-function?

Can't you ask your REPL?

Where do you see a function?

When there's no function, there's no fboundp, no macro-function, etc.
When there's no variable, there's no boundp.


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/
Until real software engineering is developed, the next best practice
is to develop with a dynamic system that has extreme late binding in
all aspects. The first system to really do this in an important way
is Lisp. -- Alan Kay
From: Bulent Murtezaoglu
Subject: Re: Macros
Date: 
Message-ID: <87hd7dycv9.fsf@p4.internal>
>>>>> "PB" == Pascal Bourguignon <······@informatimago.com> writes:
[...]
    Kenny> Can't we use macro-function?

    PB> Can't you ask your REPL?

    PB> Where do you see a function?

You are assuming Kenny and I can read.  Evidently, this is not always
true.

    PB> When there's no function, there's no fboundp, no
    PB> macro-function, etc.  When there's no variable, there's no
    PB> boundp.

Indeed.

cheers,

BM
From: Pascal Bourguignon
Subject: Re: Macros
Date: 
Message-ID: <873bix96m4.fsf@thalassa.informatimago.com>
Matt <·····@invalid.net> writes:

> Where are macros discussed in the HyperSpec?  I can't find it
> for some reason.

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

> Is the name of a macro a symbol?

Yes.

> How do I determine whether or not a symbol has been defined with
> define-symbol-macro?

(defun symbol-macro-p (object)
  (and (symbolp object) (not (eq object (macroexpand object)))))


(define-symbol-macro def abc)
(mapcar (function symbol-macro-p) '("abc" abc def))
--> (NIL NIL T)

-- 
__Pascal Bourguignon__                     http://www.informatimago.com/

"You cannot really appreciate Dilbert unless you read it in the
original Klingon"