Problem with translate_file() in Maxima-5.25.1



On 11/10/11, Kevin Gregson <kd.gregson at btinternet.com> wrote:

>         foo1(u,v):=block(
>                 define(funmake(foo2,[x,y]),x+y),
>                 translate(foo2),
>                 foo2(u,v));
> Maxima interprets this OK. But after
>         translate(foo1);
> calling foo1(2,3) produces
>  Error in APPLY [or a callee]: The function MDEFINE is undefined.

Well, this is a bug in the translator; it is generating invalid Lisp code.
I recommend pretty strongly that you shouldn't try to work around it.
I'm pretty sure there is very little to gain in execution speed,
and working around the bug will make your code substantially
more complex & less comprehensible.

> In answer to my query on how to translate and name an anonymous function,
> Robert Dodier wrote:
>
>> I suppose you could do something like:
>>
>> (defun $make_named_function (name body)
>>  (let ((my-lisp-lambda ($translate body)))
>>    (setf (symbol-function name) my-lisp-lambda)))
>>
>> Disclaimer: I didn't actually try the above code.
>
> Unfortunately, calling make_named_function() produces
>  Error in LET [or a callee]: The function $TRANSLATE is undefined.
> Is this because $translate is a special evaluation form?

Probably so -- perhaps replacing ($translate foo)
with (mfuncall '$translate foo) is enough to fix it.
I'll take another look at this problem in a few days.

best,

Robert Dodier