Rhombus is a programming language created in 2023 by Matthew Flatt.
#1431on PLDB | 2Years Old |
git clone https://github.com/racket/rhombus
Rhombus is a general-purpose programming language that is easy to use and uniquely customizable.
// simple syntax for everyday tasks
class Rect(left, top, right, bottom)
fun area(r):
let w = r.right - r.left
let h = r.bottom - r.top
w*h
area(Rect(0, 0, 10, 5))
// ⇒ 50
Feature | Supported | Example | Token |
---|---|---|---|
Pattern Matching | ✓ | // pattern matching on objects, lists, and maps class Rect(left, top, right, bottom) fun rect_like_to_rect(v): match v | Rect(_, _, _, _): v | {"LT": [l, t], "RB": [r, b]}: Rect(l, t, r, b) | {"TL": [t, l], "RB": [b, r]}: Rect(l, t, r, b) rect_like_to_rect({"TL": [0, 2], "RB": [10, 5]}) // ⇒ Rect(0, 2, 10, 5) rect_like_to_rect({"LT": [0, 2], "RB": [10, 5]}) // ⇒ Rect(2, 0, 5, 10) // pattern matching in all binding positions class Posn(x, y) fun flip_all([Posn(x, y), ...]): [Posn(y, x), ...] flip_all([Posn(1, 2), Posn(3, 4)]) // ⇒ [Posn(2, 1), Posn(4, 3)] flip_all([Posn(5, 6)]) // ⇒ [Posn(6, 5)] | |
Macros | ✓ | macro 'thunk: $body': 'fun (): $body' // > def delayed_three = thunk: 1 + 2 // > delayed_three() // 3 | |
Semantic Indentation | ✓ |