Bindings and Scoping
LFE is a Lisp-2 and has separate namespaces for variables and
functions/macros. Both variables and functions/macros are lexically
scoped. Variables are bound by lambda
, match-lambda
and let
.
Functions are bound by top-level defun
, flet
and fletrec
.
Macros are bound by top-level defmacro
/defsyntax
and by
macrolet
/syntaxlet
.
When searching for functions, both name and arity are used. A macro is
considered to have any arity and will match all functions with that
name. While this is not consistent with either Scheme (or CL) it is
simple, usually easy to understand, and fits Erlang quite well. It
does, however, require using (funcall func arg ... )
like CL to call
lambdas
/match-lambdas
(funs)
bound to variables.
Core solves this by having separate bindings and special to have only one apply:
apply _F (...)
, andapply _F/3 ( a1, a2, a3 )