On Sun, 17 Mar 2013 15:18:43 +0100
Alexander Burger <[email protected]> wrote:
> It is an important feature of PicoLisp that a construct like 'funcall'
> is NOT needed.
>
> One of the fundamental principles of the PicoLisp evaluation
> mechanisms is that the CAR of a list is evaluated, and then used as a
> function.
>
> Writing
>
> (de funcall "Args"
> (eval "Args") )
>
> (funcall (expression) 3 4)
>
> is the same as
>
> (eval '((expression) 3 4))
>
> instead of
>
> ((expression) 3 4)
>
> and thus a tautology, just with a considerable overhead.
>
>
> Moreover, if you publish code using 'funcall', new users will assume
> this is the right way to do, and use it also in cases like
>
> (de foo (Fun)
> (funcall Fun 3 4) )
You are blowing it out of proportion with that example. It's not like
users will start writing:
(funcall mapcar pack
(funcall split
(funcall chop Lst)
" " ) )
> (dm method> (Arg)
> (funcall (: hint) Arg) )
>
> (dm method> (Arg)
> ((: hint) Arg) )
Funcall is not meant for one-liners, it's meant to avoid the horrible
indentation that ((..) ..) gives in multi-line expressions:
((expression that returns a function)
(the rest of the code
((that otherwise would) not look nice when
(indented in a multi-line layout) ) ) )
where you end up with a case/cond looking layout for normal code (not
to mention what you get if you happen to have (((..) ..) ..) as
multi-line). I like this much better:
(funcall (expression that returns a function)
(the rest of the code
(funcall (that otherwise would) not look nice when
(indented in a multi-line layout) ) ) )
And it's not that much overhead anyway. From funcall to the actual
call you just get:
+ Binding of "Args"
+ Call to eval
+ Restoring of "Args"
which is as a bit less expensive than let plus one extra cell in the
prg, so it's about as costly as a let. Just that, no big deal.
--
UNSUBSCRIBE: mailto:[email protected]?subject=Unsubscribe