<div class="gmail_extra">On Tue, Dec 11, 2012 at 12:58 AM, Peter Enerccio <span dir="ltr"><<a href="mailto:enerccio@gmail.com" target="_blank">enerccio@gmail.com</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div id=":1it">Macrolet will make possible to do local macros, which are fine, but this is not what I meant. <br>What I wanted is to define macros "safely", because the code is evaluated in different thread with safe symbols, thus it is first saved <br>
as lazy function. <br></div></blockquote></div><br>You can define a global macro. You cannot apply it in the same form which defines it because it is a local form. Note that this has nothing to do with ECL, but with your understanding of Common Lisp.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px">(LAMBDA ()</span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px"> ;; Mistake 1. Assume that the forms below change the package</span></div>
<div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px"> ;; and that the IN-PACKAGE form will affect the DEFMACRO</span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px"> (LET ((CORE::P *PACKAGE*) (CORE:THIS #<a GAME:CUBE>))</span></div>
<div class="gmail_extra"> ;; This IN-PACKAGE does nothing because none of what follows</div><div class="gmail_extra"> ;; uses the value of *package*<br><span style="font-family:arial,sans-serif;font-size:13px"> (IN-PACKAGE ANCA)</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> (HANDLER-CASE</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> (UNWIND-PROTECT</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> (PROGN</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> (PROGN</span></div>
<div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px"> (DEFMACRO ANCA::RUNNABLE (&BODY ANCA::BODY)</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> (SI:QUASIQUOTE (LAMBDA () (SI:UNQUOTE-SPLICE ANCA::BODY))))</span><br style="font-family:arial,sans-serif;font-size:13px">
;; MISTAKE 2: Assume that RUNNABLE can be used right after DEFMACRO</div><div class="gmail_extra"> ;; This is not possible because this is in a LAMBDA<br><span style="font-family:arial,sans-serif;font-size:13px"> ((ANCA::RUNNABLE (PRINT "Ahoj")))))</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> (SETF *PACKAGE* CORE::P))</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> (T (CORE::X)</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> (FUNCALL</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> #<bytecompiled-closure #<bytecompiled-function 00000000032387d0>></span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> #<a GAME:CUBE></span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px"> CORE::X)))</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px"> T))</span></div><div class="gmail_extra"><br></div><div class="gmail_extra">If you want to define a macro, evaluate a form that defines it. This changes the global status of your Lisp and the macro will be available to further forms which are evaluated later.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">(defun define-my-macro ()</div><div class="gmail_extra"> (defmacro foo (a) `(print ,a)))</div><div class="gmail_extra"><br></div><div class="gmail_extra">This is a perfectly fine code. If you run</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">(define-my-macro)</div><div class="gmail_extra"><br></div><div class="gmail_extra">it will define the macro. And now you can type</div><div class="gmail_extra">
<br>
</div><div class="gmail_extra">(foo 2)</div><div class="gmail_extra"><br></div><div class="gmail_extra">and this will be translated to (print 2). That's all.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
But really, I do not understand what you want to achieve with the code above and I think you need to learn more Common Lisp before just trying to run any code.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Juanjo</div><div class="gmail_extra"><div><br></div>-- <br>Instituto de Física Fundamental, CSIC<br>c/ Serrano, 113b, Madrid 28006 (Spain) <br><a href="http://juanjose.garciaripoll.googlepages.com" target="_blank">http://juanjose.garciaripoll.googlepages.com</a><br>
</div>