root <[EMAIL PROTECTED]> writes:

>> use lots of small functions. What is the difference between
>
> This defines 2 functions.
True.
>> 
>> (defun bar (...)
>>   (blah blub))
>> 
>> (defun foo (...)
>>   (let ((...))
>>     (bar ...)))
>> 
>
> This defines a function and a "top level form".
> The first expression is evaluated and returns a function.
> The second expression is immediately evaluated for effect.
No. The DO-BAR chunk is included in the FOO chunk. Hence (BLAH BLUB)
ends up in the body of FOO and is not a toplevel form. Of course, the
two snippets differ in that one defines a function and the other does
not. But in a Lisp program I'd very much prefer the former, since it's
easier to understand and to work with. If performance is an issue, an
INLINE-declaration might help.

>> and
>> 
>> <<foo>>=
>> (defun foo (...)
>>   (let ((...))
>>     <<do-bar>>))
>> @
>> 
>> <<do-bar>>=
>> (blah blub)
>> @
>
> Depending on the situation the value of the top level form
> could have other side effects.
It is not a toplevel form.

Kai


_______________________________________________
Axiom-developer mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/axiom-developer

Reply via email to