ES version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
50% Positive
Analyzed from 1389 words in the discussion.
Trending Topics
#lisp#nil#clojure#let#tail#file#https#more#null#list

Discussion (45 Comments)Read Original on HackerNews
- 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
(1) https://news.ycombinator.com/item?id=47779659
local-time has its limits (e.g. Gregorian only), but it does everything listed in this chart
> flattening a list
What? Isn't this[1] just fine (<s>)
> hash-table literals…
Since the chart is sbcl specific, this ugly mess would technically count; a more portable (but longer) version could be made similarly using #.:
> java interop: with LispWorks or ABCL (or other libraries)I've had good luck with .net/java interop using FOIL (written by Rich Hickey prior to Clojure).
1:
=> (A B C D E F)...maybe also fivem (although I personally prefer parachute) and hunchentoot.
It's not bad but for Clojure for example it says "nil is like null in Java" but null in Java is not falsy.
And it also says that destructuring is "named parameters" but it's not so: it's just destructuring (and there are two examples of destructuring given: one for the "named parameters" which aren't named parameters, and one for "parallel assignment" of local variables).
Nothing bad but it's not possible to go into much details in such a table.
All major Common Lisps support tail call optimization with proper declarations, with the exception of ABCL because it runs on the JVM.
And those declarations are all identical or almost identical, so it's easy to write an implementation-specific macro to guarantee TCO if you need to do so.
Some algorithms are easiest to express and read with looping constructs. For those algorithms, use looping constructs. Other algorithms are easiest to express and read with recursion. For those, use recursion. You shouldn't be afraid of recursion just because ANSI doesn't say TCO is guaranteed. You should be afraid of it if your code needs to run on ABCL, but otherwise, recur on.
I prefer to write my state-machines as transitioning with tail-calls, and I do get called for it. It's relatively easy to switch something written in that manner to using a loop with a trampoline, so I do so when my collaborators request it.
Even with SBCL, for example, it doesn't have tail-call optimisation for all architectures at all optimisation levels.
https://kickingvegas.github.io/elisp-for-python/
Not only it can, but both CL and Emacs Lisp actually defines primitives with names that start with digit.
The comments make me think this is ported from scheme, which has precise TCO rules.
[edit] macroexpanded:
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.
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.
Personally I prefer lisp 1 languages, like scheme. Even there, though, there was a split over r6rs, so we got a bunch of mostly-like-r5rs schemes and racket.
Maybe the problem is that lisps are no longer popular enough to have a winning implementation! If there is one, though, then it's Common Lisp on SBCL.