<div dir="ltr">Hi<div><br></div><div>Thank you for your rapid reply</div><div><br></div><div>I am defining a library of primitives for a lazy language (with evaluation under lambda)</div><div><br></div><div>I am using the following code to define a primitive with 2 number operands:</div><div>
<p class=""><span class="">(</span>defmacro<span class=""> </span><span class="">defop2</span><span class=""> (op)</span></p>
<p class=""> `(setf (gethash ',op *prim*)</p>
<p class=""> (<span class="">labels</span> ((f (closure)</p>
<p class=""> (<span class="">if</span> (null closure)</p>
<p class=""> (function f)</p>
<p class=""> (<span class="">let</span> ((r1 (ev (car closure) (cdr closure) nil)))</p>
<p class=""> (<span class="">labels</span> ((g (closure)</p>
<p class=""> (<span class="">if</span> (null closure)</p>
<p class=""> (function g)</p>
<p class=""> (<span class="">let</span> ((r2 (ev (car closure) (cdr closure) nil)))</p>
<p class=""> (<span class="">if</span> (and (numberp r1) (numberp r2))</p>
<p class=""> (,op r1 r2)</p>
<p class=""> `((,',op ,r1) ,r2))))))</p>
<p class=""> (function g)</p>
<p class=""> )))))</p>
<p class=""> (function f))))</p><p class="">I was thinking that maybe there is a better way without using LABELS</p><p class=""><br></p><p class="">Kind regards</p><p class="">Taoufik</p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Apr 22, 2015 at 1:15 PM, Stas Boukarev <span dir="ltr"><<a href="mailto:stassats@gmail.com" target="_blank">stassats@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Taoufik Dachraoui <<a href="mailto:dachraoui.taoufik@gmail.com">dachraoui.taoufik@gmail.com</a>> writes:<br>
<br>
> Hi<br>
><br>
> is it possible to reference a function inside its body<br>
><br>
> I would like to have something equivalent to the following without using<br>
> eval:<br>
><br>
</span>> *(funcall (funcall (funcall #1=(lambda (n) (if (= n 0) (eval '#1#)<br>
> #2=(lambda (m) (if (= m 0) (eval '#2#) (+ n m))))) 0) 3) 5)*<br>
><br>
LABELS<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
With best regards, Stas.<br>
</font></span></blockquote></div><br></div>