35 ms·
I've been experimenting with various riffs on Common Lisp for about thirty years now, and eating my own dog food. I've found four things that turn out to be hu
by lisper 9y ago
I've been experimenting with various riffs on Common Lisp for about thirty years now, and eating my own dog food. I've found four things that turn out to be huge levers for me:
1. Python-style iterators. No matter what I want to iterate over, I just write:
(for item in thing do ...)
or if I want to collect the results:
(for item in thing collect ...)
2. A universal binding construct, which I call binding-block or BB for short. It aggressively eliminates parens so that my code ends up looking like:
(bb var1 (expression)
var2 (expression)
...)
3. Generic functions, and in particular a set of standard generic functions that perform the most common operations on any data type. For example REF dereferences anything. It replaces ELT, NTH, SLOT-VALUE and AREF and even certain database queries.
4. Classes, with very light use of inheritance.
For an example of code written in this style, take a look at:
https://github.com/rongarret/tweetnacl/blob/master/ratchet.lisp https://github.com/rongarret/tweetnacl/blob/master/ratchet.l...
You can transfer some of this to other languages, e.g.:
https://github.com/rongarret/ratchet-js/ https://github.com/rongarret/ratchet-js/