by bjoli · 7y ago · 0 comments
Being able to add features like that is amazing. Clojure'sarrow syntax? No problem. Python's list comprehensions? Can be done! A library for Pattern matching? Many to chose from!
Pattern matchers that were added to other languages as libraries are often weird to use. Match.scm has the same syntax as cond or case.
If such a macro is used in more than two places, it's generally a relief that the author did that instead of doing copy and paste by hand.
The author had some coding idea, and formalized it into a little robot that writes that idea, which has a name.
Even if that thing isn't accompanied by documentation, it can serve as a kind of documentation to what it's doing.
Code is going to be full of homemade functions that are not documented; whether they are functions that write code at compile time, or whether they are run-time functions, is kind of a minor concern.
Most macros are just simple syntactic abstractions that expands simple code to more lines of relatively simple code to avoid boilerplate. Very rarely do people write complex beasts without documentation.
The minimizing and maximizing constructs are surprisingly readable.
I have an implementation of rackets loops for guile scheme, and I'm currently rewriting it to allow arbitrary transformations in the loop clauses.
Say I want to write a Fibonacci loop, currently I can't do this:
(for/list ((a :first 0 :then b) (b :first 1 :then (+ a b))) a)