Tree @master (Download .tar.gz)
rubbish.md @master — view markup · raw · history · blame
Basic types
Rubbish features a typical set of built-in values: integers which transparently become bignums, floating-point numbers, functions, tuples, and the soon-to-be-explained variants. Every missing value is represented by these. (Technically, numbers and tuples could be subsumed by variants---and are, in the semantics---but practically, they are treated as separate due to their wide use.)
Variants are an untyped version of the tagged sums featured in statically typed functional languages. A variant always begins with either a capital letter or a backtick.
Nullary variants are treated not unlike symbols in Lisps or Ruby. The
only meaningful operations on them are comparison or pattern-matching.
Certain nullary variants are used as distinguished values; for example,
False
is the false value and Void
is the return type of most
side-effectful functions. In addition, nullary variants subsume most
uses of enumerations and function as keywords, e.g.
file := open("filename.txt", R)
.
However, variants can also take an arbitrary number of arguments. For
example, evaluating Point(1, 2+3)
results in the value Point(1, 5)
;
the intuition behind them can be captured in a number of ways: you
can think of an n-ary variant as an (n+1)-ary variant with a symbol
as its first element, or as