Object oriented Lambda Calculus

From Esolang
Jump to navigation Jump to search

Object-oriented Lambda Calculus is an esolang created by User:Joaozin003 which extends Lambda-calculus by adding classes.

Classes

Just like functions, classes are anonymous, but their members are referred to by name. To define a class, use ~(body).

The body is a list of names and function definitions, in this format: ival:if;name1(att1):f1;name2(att2):f2;...

Functions can refer to a this variable, which gets the object's instance.

All functions set a specific attribute. For example, if you want to use foo to change the attribute bar, you would do:

~(ival:baz;foo(bar):body;bar:qux;)

The return value is what bar would get set to.

To access an attribute, put the attribute's name in single quotes after the instance. Example:

~(ival:\f.\x.x;succ(val):\f.\x.f (this'val' f x))'succ'

See the val attribute? If an instance gets evaluated by itself, it's as it did instance'val'.

ival is the initial value.