by School-Cotton · 1y ago · 0 comments
Devs in the 90s were handed a language that looked like a weird Java and so they programmed it like a weird Java. If they were handed a language that looked like Lisp instead, maybe they would have made their way to SICP that much sooner.
Sure, but CL also culturally has a long history of macro-ridden code that make it harder to understand other people's code.
We already suffer from dozens of JS frameworks. Just imagine what it would look like under a CL-dominant world...
Idk man, every time someone makes that claim my immediate reaction is: "what's the catch?". I much rather use 5 tools designed for specific purposes than general-purpose tools that are 50% good at 5 tasks.
> you can literally pause on an exception, rewind, fix your code and continue from where you left off.
Does it only work on source codes or can I distribute a binary and let my users debug the code like this? Should I distribute the 'image' for it to work?
And is the fix temporary (until the program dies) or permanant?
I think, Lisp in general is very flexible - you can write imperatively, or you can do more FP; if you need object-orientation - you have it, polymorphic dispatch - sure why not?, etc., etc.
Link to book on Amazon: https://www.amazon.com/dp/0367350203
(defun double-numbers (numbers)
"Doubles a list of NUMBERS.
Docstring and type declarations are optional."
(declare (type List numbers))
(mapcar (lambda (x)
(declare (type Number x))
(* x 2))
numbers))
(defun double-numbers (numbers)
(labels ((accumulate-loop (nums acc)
(if (null nums)
(funcall acc nums)
(destructuring-bind (first-number &rest other-numbers)
nums
(accumulate-loop other-numbers
(lambda (result)
(funcall acc
(cons (* first-number 2)
result))))))))
(accumulate-loop numbers (lambda (result) result))))
(defun double-numbers (numbers)
(if (null numbers)
numbers
(cons (* (first numbers) 2)
(double-numbers (rest numbers))))
(defun double-numbers (numbers)
(loop :for number :in numbers
:collect (* number 2)))
(defun double-numbers (numbers)
(if (null numbers)
numbers
(prog ((remaining-numbers (rest numbers))
(first-pair (list (* (first numbers) 2)))
last-pair)
(setf last-pair first-pair)
:start-loop
(when (null remaining-numbers)
(return first-pair))
(setf (rest last-pair)
(list (* (pop remaining-numbers) 2)))
(setf last-pair (rest last-pair))
(go :start-loop))))
And that's before going into libraries like SERIES or iterate. There are, of course, benefits and disadvantages (readability, performance, some CL implementations don't do TCO,...) to every option, but generally CL lets you code in any way you want (you could even write some macros to let you write it using more infix or postfix style syntax, but I don't see the appeal of doing so).