Skip to content
Silvio Mayolo edited this page Jul 9, 2020 · 5 revisions

Latitude

The language that lets you think laterally

Latitude is a prototype-based programming language with first-class scopes and full continuation support. Unlike a traditional, class-based language, a prototype based language treats classes as simply additional objects. This approach allows the object-oriented principle of inheritance to be used in a more general way.

As a specific example, Latitude supports first class scopes. When a method is defined, it is given a lexical closure (nothing special here; this is how most languages work). The method's closure, however, is an object which inherits from the enclosing lexical scope.

a := 1.
do { a println.
     a := 2.
     a println. }.
a println.
; Prints 1, 2, 1

So far, this is nothing particularly extraordinary. Most languages have scoping rules something like this. The key difference is that in most languages, this is done silently behind the scenes, while in Latitude, scopes are objects just like any other.

a := 1.                        ; Most variables are implicitly lexical.
do { myScope := lexical.       ; This gets the current lexical scope, as an object.
     myScope a := 2.           ; Here, we change the variable a in the current scope.
     myScope parent a := 3. }. ; However, this line changes the a variable in the parent scope.
a println.                     ; Prints 3.

Scopes fit very well into a prototype-oriented mindset, and the idea of scopes inheriting from enclosing scopes comes free with the generalized notion of object inheritance. Scope inheritance cannot be expressed in terms of class inheritance, as scopes are instances, not classes in and of themselves.

Tutorial: http://mercerenies.github.io/latitude/tutorial/

Language Specification: http://mercerenies.github.io/latitude/spec/

Clone this wiki locally