What type of lambda calculus would Lisp loosely be an example of?

后端 未结 3 670
梦谈多话
梦谈多话 2020-12-28 14:30

I\'m trying to get a better grip on how types come into play in lambda calculus. Admittedly, a lot of the type theory stuff is over my head. Lisp is a dynamically typed la

3条回答
  •  天命终不由人
    2020-12-28 15:01

    Lisp is a dynamically typed language, would that roughly correspond to untyped lambda calculus?

    Yes, but only roughly. In the "pure" untyped lambda calculus, everything is coded as functions. (You can google for the popular "Church encoding" and the less popular "Scott encoding".) Lisp has non-functional data, like atoms and numbers and such, so this would count as "untyped lambda calculus extended with constants."

    Another important difference is in order of evaluation. Rules for reducing lambda-calculus terms are highly nondeterministic. (There's a theorem, the Church-Rosser theorem, which says loosely that as long as things terminate, order of evaluation doesn't matter.) In practice lambda terms are typically reduced using leftmost-outermost aka "normal-order" reduction because if any reduction strategy terminates, that one does. This is very different from Lisp which always evaluates arguments to normal form before doing a beta-reduction. This evaluation order is called "call by value."

    In summary, Lisp corresponds to an untyped, call-by-value lambda calculus extended with constants.

提交回复
热议问题