Continuing from The fanciest define of all time
First of all, that I’ve set up an Emacs shortcut to reset the defines has proven invaluable. It would be pretty much impossible to use otherwise. When working with the REPL, which I like to do, I need to be able to clear out the values after mistakes and non-working attempts and then re-eval them all. This is not needed when defining simple values but is needed when defining functions.
Second of all, when there are multiple defines, they need to be in the
right order. most generic first and most specialized last. This is
backwards from match-define
/ match-lambda*
. Both by design
because that’s how I thought I wanted it, and by ease of
implementation since it is consing.
These two hurdles have been an obstacle when programming and I need to remain open-minded that this fanciest define feature of brev might be better off on the cutting room floor. The more used I personally get to working around the aforementioned hurdles, the less qualified I become to judge how inaccessible and beginner-hostile brev becomes.
I really hope they can stay in, because o are these defines ever sweet.
Just the symmetry of being able to do something like
(define ((frobnicate proc) (key . val)) (proc val))
I also stumbled upon a new feature. For someone who basically turned define into a wrapper for matchable, I don’t know matchable very well yet. It can detect when two things are the same:
(define (make-gap () key) '())
(define (make-gap (call . path) key)
(cons call (make-gap path key)))
(define (make-gap (call . path) call)
(cons (cons 'M (take-right call 2)) path))
This is awesome!
I’ve also sometimes evalled my older code while still having these defines still loaded and it still works. It clutters up the gentable but then defines them normally. It detects that I’m not using any matchable features.
That is also where the “most specific last” thing has turned out to be the right design. If I’ve left
(define (foo bar) ... do this..)
(define (foo bar) ... on second thought, do this instead ... )
it still works.