On May 2, 9:24 am, Kaz Kylheku <kkylh...@[EMAIL PROTECTED]
> wrote:
>
> Order is perhaps the number of levels of indirection you must
> dereference to actually call a function which just returns or accepts
> a plain datum.
>
> Lambda increases order, funcall decreases.
>
> ;; fourth order function:
>
> (defvar *fourth-order*
> (lambda () (lambda () (lambda () (lambda () '("hello"
> "world"))))))
Usually, order is the nesting depth of functional _arguments_. The
notion is easy to understand when you look at types. Say you have a
language that has only functions, tuples, and int. Then the standard
definition of order would:
order(int) = 0
order(t1*t2) = max(order(t1), order(t2))
order(t1->t2) = max(order(t1)+1, order(t2))
That is, a function of type int->int is first-order, while ((int->int)-
>int)->int is third-order. Note however that your example would have a
type like A->(B->(C->(D->E))), and thus actually is a first-order
function - at least according to the standard definition in logic. The
reason for this definition is that via (un)currying this type actually
is isomorphic to A*B*C*D->E, which clearly is first-order. So
_returning_ a function does not raise order, unless that function is
higher-order itself. Plain curried functions are still first-order.
- Andreas


|