4 ms·
Easy in Common Lisp without sacrificing ergonomics or getting stuck in a Turing tarpit. We'd make a small preamble to define new names for things like DEFUN, L
by reikonomusha 2y ago
Easy in Common Lisp without sacrificing ergonomics or getting stuck in a Turing tarpit.
We'd make a small preamble to define new names for things like DEFUN, Lisp's operator to define new functions. No F's needed to do that either. We can do this by taking advantage of read-time evaluation.
First we get references to the symbols DEFMACRO and DEFUN.
(eval-when (:compile-toplevel :load-toplevel :execute)
(setq de*un (intern (map 'string 'code-char '(68 69 70 85 78))))
(setq de*macro (intern (map 'string 'code-char '(68 69 70 77 65 67 82 79)))))
This technique can be used to access any symbol in Common Lisp that may have an F in it.
Now, to make life-without-F easy, we define new names for DEFMACRO (mac) and DEFUN (proc) without actually lexically referring to the F-infected symbols:
(#.de*macro mac (&body r) `(,de*macro ,@r))
(mac proc (&body r) `(,de*un ,@r))
Now we can define functions with PROC instead of DEFUN. Here's the Fibonacci function, with the F censored out. Note that we don't need IF since Lisp has the superior COND:
(proc *ib (n)
(cond
((= 0 n) 0)
((= 1 n) 1)
(t (+ (*ib (- n 1)) (*ib (- n 2))))))
Test it:
> (print (*ib 10))
55
- benrutter 2y agoThis is excellent! I was playing around with a lisp (hy) recently, and hadn't really used macros before then. It's amazing how much you can reengineer lisp from within to meet your needs, even if they're as small as "I don't want to use F". I haven't seen any non-lisp languages that give you that kind of power, for better or worse.
- amenhotep 2y agoI think that's cheating. 70 is just F with a different hat on.
- reikonomusha 2y agoWould it be better for you if we took the Nth symbol in alphabetical order from the list of 978 standard symbols? You could do that. How about searching for all symbols with the letters DEMACRO that are 8 letters long? We could do that too. The technique works so long as you can uniquely determine the symbol through some combination of standard Lisp functions that don't contain F. Lisp has a big library, so it's not tough. "70" isn't a number that is associated to F in any common person's understanding, and the pronunciation of the number "70" in English has no objectionable F sounds, so I don't agree it's cheating. :)
- kagevf 2y agoA garbage reddit post produces this great comment - only on HN! :) And somehow, my reply managed to avoid using that letter ...