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
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/
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
>>>>> "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
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
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.
>>>>> "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
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
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
>>>>> "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
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"