Lithe (horse)
   HOME

TheInfoList



OR:

Lithe is an experimental
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
created in 1982 by David Sandberg at the
University of Washington The University of Washington (UW and informally U-Dub or U Dub) is a public research university in Seattle, Washington, United States. Founded in 1861, the University of Washington is one of the oldest universities on the West Coast of the Uni ...
which allows the programmer to freely choose their own syntax. Lithe combines the ideas of
syntax-directed translation Syntax-directed translation refers to a method of compiler implementation where the source language translation is completely driven by the parser. A common method of syntax-directed translation is translating a string into a sequence of actions by ...
and classes in a novel manner that results in a remarkably simple yet powerful language.


Overview

The standard
class-based programming Class-based programming, or more commonly class-orientation, is a style of object-oriented programming (OOP) in which inheritance (object-oriented programming), inheritance occurs via defining ''class (computer programming), classes'' of object ( ...
model does not specify a mechanism by which to manipulate objects: where
Smalltalk Smalltalk is a purely object oriented programming language (OOP) that was originally created in the 1970s for educational use, specifically for constructionist learning, but later found use in business. It was created at Xerox PARC by Learni ...
uses message passing, Lithe uses
syntax-directed translation Syntax-directed translation refers to a method of compiler implementation where the source language translation is completely driven by the parser. A common method of syntax-directed translation is translating a string into a sequence of actions by ...
(SDT). SDT is a method of translating a string into a sequence of ''actions'' by attaching one such action to each rule of a grammar. Thus, parsing a string of the grammar produces a sequence of rule applications. Lithe merges SDT with the class model by using classes as the non-terminal alphabet of the grammar. Since the grammar class used by Lithe properly contains all context-free grammars, a wide variety of syntax can be described, and SDT provides a simple way to attach semantics to any such syntax. The ''package'' is the unit of program modularity in Lithe. A package is divided into two parts: one that defines classes and another that defines rules.
Information hiding In computer science, information hiding is the principle of segregation of the ''design decisions'' in a computer program that are most likely to change, thus protecting other parts of the program from extensive modification if the design decisio ...
is achieved by requiring both ''export'' keywords on those rules and classes that are to be seen outside a package ''and'' that the source package names be included in the ''with'' clause of the consumer package.


Examples

Programming in Lithe consists of defining rule-action pairs and classes. Take the task of computing the
absolute value In mathematics, the absolute value or modulus of a real number x, is the non-negative value without regard to its sign. Namely, , x, =x if x is a positive number, and , x, =-x if x is negative (in which case negating x makes -x positive), ...
of a number, for example: rule ", " <i:int> ", " return int; {if i<0 then return -i else return i end} After this rule-action pair has been defined, it can be freely used within Lithe source code, for example, the following expression will thereafter be valid: , x - y, + 3 The equivalent rule in BNF would be: <int> ::= ", " ", " Note that the Lithe description swaps the left and right sides of the BNF one, then adds a name to each nonterminal in the BNF right-hand side. These names are used in the action part, which is expressed as a string that is translated into a sequence of actions by using other, previously defined, rule-action pairs (eventually, some of those rule-action pairs will invoke primitive actions).


External links


"Lithe: a language combining a flexible syntax and classes"
Declarative programming languages Experimental programming languages Extensible syntax programming languages