The Rhombus Programming Language
56 points by spdegabrielle
56 points by spdegabrielle
Rhombus is ready for early adopters. Learn more and get it now at https://rhombus-lang.org/
pattern matching in all binding positions
Yes! This was one of my main pain points with Scheme, that using pattern-matching is doable via macro but is unpleasant in practice because it requires explicitly switching to different, more cumbersome binder constructs.
The macro system looks so easy to use.
I know it’s a bit superficial, but I love a most of this except the choice to use ::
for type annotations.
Very cool to see the operator overloading uses relative precedences as opposed to numbers – I wish more languages did that. It was proposed for Agda at one point, and I think Swift does similar with its precedence groups.
This example from the homepage does not make sense to me:
// 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)]
How is it that flipping the arguments in the rest ...
is inferred?
You can click on any syntax in those examples! That brought me to … which links to repetitions which explains how it works.
Oh wow. Huh. That’s pretty subtle. I kind of expected it to “just” be argument forwarding like in Ruby/C++.
That looks cool and it’s impressive, but I rather use .map instead
It has .map too https://docs.racket-lang.org/search/index.html?q=.map
Like Function.map and Function.for_each, but with a single list of arguments first, with the function supplied second.
> List.map([1, 2, 3], (_ + 1))
[2, 3, 4]
> [1, 2, 3].map((_ + 1))
[2, 3, 4]
> [1, 2, 3].for_each(println)
1
2
3
This looks like the treatment of …
in syntax-rules
and syntax-case
from Scheme. One would imagine, given the origin of Rhombus, that’s the inspiration.
In the Emacs guide, it mentions somewhere using different indentations (single, double, triple, space) (between words, sentences, paragraphs) and Rhombus’ shrubbery seems to do the opposite. Instead of indenting the start more, with less indented things being within it, the sub-parts are indented more.’
(func (func arg arg) (func arg arg) - begin ( and end ) seperators
—func –func -arg -arg –func -arg -arg (using - to represent a separator, a single marker!)
-func –func —arg —arg –func —arg —arg <- seems like shrubbery, if I understand correctly (but using new lines and indentation instead of -))
This is just racket with lots of syntax right?
A syntax that brings the extensibility of Racket to a broader audience. Binding spaces for context-specific sublanguages is cool. It has some other tricks too…
I agree; I like that this is really trying to follow through on the problem. There have been a million attempts to put a non-paren syntax on top of Scheme, but they rarely get past essentially syntactic sugar for Scheme implemented with a straightforward translator. The Rhombus people are trying to make macros actually work well in their new syntax, support ergonomic and extensible pattern-matching, adapt Racket-style #lang extensibility to work well in the new syntax, etc. Seems promising at least.
Ooh interesting. I read about this long ago, way before it was called Rhombus IIRC, and thought it was fine but basically the same as many previous attempts such as wisp. But what they’ve done with macro syntax seems to be really new.