My most charitable take is that it solves some problems I never seen a computer language have.
My most charitable take is that it solves some problems I never seen a computer language have.
fun is_sorted(list):
match list:
| []: #true
| [_]: #true
| [head, next, tail, ...]:
head .<= next && is_sorted([next, tail, ...])
There's also a dot in `head .<= next`, because the syntax is sugar for `head.<=(next)`. Not sure why this is needed, but a quick read on the docs suggests this is done to enable static dispatch for some calls.And how would the last line look if the previous one didn't end in a colon?
The global project might be nice, but in this particular case it's kind of opt for worst of all pre-existing conventions while trying to please everyone. The challenge is tough, so that's no wonder it will have hard time matching the goal.
fun is_sorted(list):
match list:
| []: #true
| [_]: #true
| [head, next, ...]:
head .<= next && is_sorted([next, ...]) $ raco pkg install rhombus --auto
which should work if you have some vaguely recent install of racket on your machine and handle the dependencies without prompting.(I started installing this several hours ago on a slow machine but it's still going.)
Please file a bug report so this can be tracked down.
In that case, I make it quick - and refrain from any followup questions.
Did you by chance pick the "Minimal Racket" distribution?
If so, your command essentially compiled large parts of Racket and generated the entire set of documentation.
The distribution "Full Racket" is the recommended distribution for most purposes. It comes with everything pre-compiled.
https://github.com/termux/termux-packages/blob/master/packag...
I just installed the package called `racket` from Termux's upstream, and it seems that they're using racket-minimal for that. Bit of a gotcha, but at least it doesn't seem like there's a bug. Thanks for the tip.
I'll contact the Termux people and ask if the choice of `racket-minimal` was intentional.
~ $ racket -I rhombus
Welcome to Racket v8.13 [bc].
> fun is_sorted(list):
match list:
| []: #true
| [_]: #true
| [head, next, ...]:
head .<= next && is_sorted([next, ...])
; readline-input:6:19: next: cannot use repetition binding as an expression
; in: next
; [,bt for context]
From there I got to "repetition binding" in the docs: https://plt.cs.northwestern.edu/pkg-build/doc/rhombus/Repeti...From what I can understand, the "..." isn't independent of the previous expression in the list (as I would have expected from e.g. Prolog or Haskell). Instead you are defining a kind of pattern to reuse later, so tail gives a name to the rest of the list (so that it doesn't get associated with next).
They are also using : ; , and a new line. Also ' and << >> that I have no idea how to type.
They are using both :~ and :: for type hints.
In none of the languages I've seen that was necessary or useful.
I think the problem they were solving was ... we really want to be able to cram everything into one line, so even if you split lines you might just as well still use the same characters despite them being unnecessary then.
It's a general mechanism to associate an expression with "extra information" that can be used elsewhere (at compile time).
One can for example using static information to implement dot notation for an object system. Using static information, one can push name resolution from runtime to compile time.
The important part is that users of Rhombus can use the mechanism for tracking static information specific for their programs.
It will be exciting to see the creative uses of this mechanism in the future.
Compiler can tell if a thing is static or dynamic and apply the correct behavior. Why would I ever want to check static thing only dynamically and why would I ever want to try statically check dynamic type if not by mistake?
If programmer doesn't really have a real choice why make him choose which buttons to press?
In a language like MetaPost I can use equations between variables:
x + y = 10
x - y = 6
A reference to a variable x will use the current set of equations and solve for x. The solution (it it exists) will become the value of the variable reference.Let's say I want to extend Rhombus with this new kind of variable (let's call them linear variables).
Each linear variable needs to have some static information attached. Here the relevant information is the set of equations to consider. A reference to a linear variable will then reduce (at compile time) the equations associated with the variable. The reduced set of equations is then used to generate runtime code that finds the value.
In a sense "static information attached to an expression" is just a convenient way of working with compile time information (in the sense currently used by macros in Racket).
It sounds a bit like if every C function (including hello world) had to have empty asm block because someone might need it some day.
The operator `expr :: annot` will at runtime insert a check that the expression satisfies the annotation.
Yes.
As an example Matthew Flatt has implemented Shplait in Rhombus: