I know that the purpose of the page is to compare syntax of common lisp, racket, clojure, and emacs lisp.
But some examples could be more idiomatic, for instance instead of
(defun add (a &rest b)
(if (null b)
a
(+ a (eval (cons '+ b)))))
One should avoid eval and use endp instead of null:
(defun add (a &rest b)
(if (endp b) a
(apply #'add (+ a (first b)) (rest b))))
Something I've been meaning to do is try putting together a cross-lisp package manager -- if only because it'd be fun. Maybe it would favor code that could be readily run or eval'd or maybe with some sort of clj/cljs type dynamic dispatch for anything implementation specific.
The page indicates that there is not function for documentation in common lisp, but
(documentation 'documentation 'function)
"Return the documentation string of Doc-Type for X, or NIL if none
exists.
System doc-types are VARIABLE, FUNCTION, STRUCTURE, TYPE, SETF, and T.
Also http://rosettacode.org for computer tasks implemented in many computer languages to allow you compare syntax and code.
But makes me think we'd be better off if we all just focused on a single one, and grew it, made it better. Not having 4 versions of something almost identical. Fragmentation can hurt adoption.
As someone who's not a programmer but has beginner - medium python & C skills. I'm in middle of learning lisp (elisp to be precise) and it feels like reading poetry. It's a transcendent experience that's hard to explain. Such beautiful concepts. Everything flows in a way it doesn't in C based langs
- why nothing on the "compiler" line? Everytime you load a snippet or a file with SBCL, it compiles it (to machine code). There's also compile-file.
- interpreter: likewise, all code is compiled by default with SBCL, not interpreted, even in the REPL. To use the interpreter, we must do this: https://github.com/lisp-tips/lisp-tips/issues/52
- command line program: the racket cell shows the use of -e (eval), the same can be done with any CL implementation.
- since the string split line introduces cl-ppcre, one could mention cl-str :D (plug) (much terser join, trim, concat etc)
- ah ok, for dates and times, flattening a list, hash-table literals… we need more libraries.
Hash-table literals are covered by (among others):
- Serapeum
- golden-utils
- rutils
- make-hash
Though now I'm wondering which libraries would make for a proper canonical extended core... asdf, uiop (comes with asdf, so naturally), alexandria, bordeaux-threads, cffi, cl-ppcre, str, local-time, trivia,... and maybe fset? (although I personally prefer Sycamore's naming conventions)
...maybe also fivem (although I personally prefer parachute) and hunchentoot.
I didn't try macroexpanding it yet, but when I make the 9 a runtime-parameter, I eventually get a stack-overflow with SBCL not TCO-ing the "H" binding in labels.
The comments make me think this is ported from scheme, which has precise TCO rules.
17 comments
[ 3.3 ms ] story [ 42.6 ms ] threadSomething I've been meaning to do is try putting together a cross-lisp package manager -- if only because it'd be fun. Maybe it would favor code that could be readily run or eval'd or maybe with some sort of clj/cljs type dynamic dispatch for anything implementation specific.
https://www.gnu.org/software/emacs/manual/html_mono/cl.html
But makes me think we'd be better off if we all just focused on a single one, and grew it, made it better. Not having 4 versions of something almost identical. Fragmentation can hurt adoption.
- why nothing on the "compiler" line? Everytime you load a snippet or a file with SBCL, it compiles it (to machine code). There's also compile-file.
- interpreter: likewise, all code is compiled by default with SBCL, not interpreted, even in the REPL. To use the interpreter, we must do this: https://github.com/lisp-tips/lisp-tips/issues/52
- command line program: the racket cell shows the use of -e (eval), the same can be done with any CL implementation.
- since the string split line introduces cl-ppcre, one could mention cl-str :D (plug) (much terser join, trim, concat etc)
- ah ok, for dates and times, flattening a list, hash-table literals… we need more libraries.
- more files operations: https://lispcookbook.github.io/cl-cookbook/files.html
- emacs buffers: now compare with Lem buffers 8-)
- posix-getenv: I'd rather use uiop:getenv (comes in implementations).
- uiop:*command-line-arguments*
- exit: uiop:quit
- uiop:run-program (sync) / launch-program (async)
- java interop: with LispWorks or ABCL (or other libraries)
my 2c
...maybe also fivem (although I personally prefer parachute) and hunchentoot.
https://kickingvegas.github.io/elisp-for-python/
The comments make me think this is ported from scheme, which has precise TCO rules.
[edit] macroexpanded:
Not only it can, but both CL and Emacs Lisp actually defines primitives with names that start with digit.