4 ms·
The Paul Graham school of Lisp, and of Arc, is well on display with these small pure functions with cryptic names. He used to say functions that are used often
by sph 3y ago
The Paul Graham school of Lisp, and of Arc, is well on display with these small pure functions with cryptic names. He used to say functions that are used often should be shortened as much as possible. Life is too short to write `getElementById` 30 times a day. In Arc (or was it Bel), even `defmacro` got shortened to `mac`.
I might not agree completely, but I see the wisdom in it.
- hnfong 3y agoThat corroborates our suspicion that lisps (and lispers) are "write once, read never" languages. For most of us less insane folks, we like to be able to read our code. Interestingly, Paul Graham seems to not have taken this approach towards writing. I mean, if u can omit bnch o chars in wrds & stll gt the meanin acrx, why bthr wrtin ful wrds or sntnces?
- sph 3y agoGroan.
- mminer237 3y agoThis might have made sense 20 years ago, but it kind of assumes you're writing code in Notepad. Literally, I type `g` + `Tab` to get an element. I would spend multitudes more time guessing what functions mean than I would typing.
- kazinator 3y agoI also agree 90%. However, when you shorten defmacro to mac, you break tooling. Here is an example. Let's put this into a file called file.lisp: (defmacro foo ()) (defwidget widg ()) ;; I just made up defwidget: it doesn't exist! (mac bar ()) Now, let's run Exuberant Tags (ctags): $ ctags file.lisp $ cat tags !_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/ !_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/ !_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert@users.sourceforge.net/ !_TAG_PROGRAM_NAME Exuberant Ctags // !_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/ !_TAG_PROGRAM_VERSION 5.9~svn20110310 // foo file.lisp /^(defmacro foo ())$/;" f widg file.lisp /^(defwidget widg ())$/;" f Hey look, ctags recognized my defwidget invention and index widg as a tag. Where is Graham's mac? Always call your custom definers defsomething, and put them in the first column as (defsomething name* ...*. Then ctags will index you custom defined constructs. Also, saving a couple of character in defining a macro is false economy, because a macro should be used at least several times and considerably condense your program and make it more readable. defmacro is already abbreviated; it could be define-macro which would be bad. defmac is a nice possibility.