Re: Macros and symbols across packages
- From: Pascal Bourguignon <pjb@xxxxxxxxxxxxxxxxx>
- Date: Sun, 29 May 2005 08:27:43 +0200
"Jeff M." <massung@xxxxxxxxx> writes:
> I'm curious if there is a method of making sure that symbols will
> evaluate "properly" across packages for use in a macro. For example, I
> have a package that will generate ARM assembly code like so:
>
> (addne r0 r0 r1 :lsl 4) => #x...
>
> Of course, when I use these macros from outside the ARM package,
> though, none of my symbols (registers) match those in the ARM package.
> The only two ideas I can think of to ensure that they match would be
> to:
>
> 1. Modify the instruction macro to always intern register symbols into
> the current package (bad, IMO, but only for gut reasons) or
The point is not that it's bad, it's that the symbols are interned by
the _reader_!
> 2. Create a reader character macro that will change which package I'm
> in for the rest of the read:
>
> { (addne r0 r0 r1 :lsl 4) }
Or you could just write: (in-package "ARM")
or just (use-package "ARM"), having taken care of exporting these symbols.
> I'm willing to do (2) if that is general practice, but I was hoping
> there might be something else I can do that may be a simpler solution
> (as I have a lot of assembly code already in place -- I just recently
> put the ARM macros in its own package.
You could write:
(use-package "ARM") (addne r0 r0 r1 :lsl 4)
or: (arm:addne arm:r0 arm:r0 arm:r1 :lsl 4)
or: (arm:addne :r0 :r0 :r1 :lsl 4)
or: (arm:addne "r0" "r0" "r1" :lsl 4)
or, now that you're ready to use STRING-EQUAL instead of EQL,
(addne mypackage::r0 the-other-package::r0 :r1 :lsl 4)
(and (string-equal 'r1 :r1) (string-equal 'p1::r1 'p2::r1))
--
__Pascal Bourguignon__ http://www.informatimago.com/
Our enemies are innovative and resourceful, and so are we. They never
stop thinking about new ways to harm our country and our people, and
neither do we. -- Georges W. Bush
.
- References:
- Macros and symbols across packages
- From: Jeff M.
- Macros and symbols across packages
- Prev by Date: Macros and symbols across packages
- Next by Date: Statistics for comp.lang.lisp
- Previous by thread: Macros and symbols across packages
- Next by thread: Re: Macros and symbols across packages
- Index(es):
Relevant Pages
|
|