Minis
Random things I wanna write down
Pages
@ Syntax
2026-03-14 • 🕐 1min • 85 wordsAda has a neat syntax since 2021.
X := @ * 2;
The @ always signifies the LHS of the assignment.
Even in more complex situations like this:
Cursor(3, Next) := @ * 2 + Sqrt(@);
It’s a very nice way of doing all the +=, *=, |=, <<=, etc.
which seems slightly more readable to me, for the
basic cases I still learnt to see :=@+ as a +=,
and in the more complex expressions where you don’t actually
want to just have the final operation be + the old value,
it comes in way more handy.
Ofc doing this with macros is trivial.
OCaml has curried keywords
2026-03-14 • 🕐 1min • 122 wordsI spoke about keywords improving readability in an older post.
And actually found something that does it close to what I described.
OCaml calls it “Labelled Arguments”:
# x + y;;
# add ~x:2 ~y:4;;
- : int = 6
# add ~y:2 ~x:5;;
- : int = 7
# add ~y:4;;
- : x:int -> int = <fun>
Sadly you can’t do something like add ~x to remove the label from
the argument, it’s a labelled argument, it’s a different type
and that’s that unless you wrap it in a lambda.
They also have an interesting approach to optional arguments, where you can just skip over them when applying a later label? This of course means you need a sentinel value if there are no non-optional arguments and also that optional arguments come first rather than last.