I just wish a good IDE existed so I don't have to use Emacs. That's what made me drop lisp in the past. I would be happy with (neo)Vim setup as well, but that was way behind Emacs and broken when I tried.
A Road to Lisp: Which Lisp
171–180 of 180 posts
Re: A Road to Lisp: Which Lisp
#172Re: A Road to Lisp: Which Lisp
#173Earlier quoted context omitted.
I'd have used (funcall (ecase operation (:add '+) (:subtract '-) (:multiply '*)) result value) instead, looks funkier =)
Did you know CL allows keywords to be function names? [1]> (setf (symbol-function :add) (function +)) # [2]> (setf (symbol-function :subtract) (function -)) # [3]> (setf (symbol-function :multiply) (function *)) # [4]> (setf (symbol-function :divide) (function /)) # [5]> (reduce (lambda (x y) (funcall (car y) x (cadr y))) '((:add 5) (:multiply 3) (:subtract 4)) :initial-value 0) 11 This is actually a small benefit of…
But this made me realize there's no way in CL (even with PROGV shenanigans) to temporarily bind the function value of a symbol, unlike the variable one through a simple LET =(
So this turns in this horrible (and incorrect, since this doesn't restore the previous FDEFINITIONs) thing when you want to use this hack "properly":
(defun calculate (instructions)
(setf (symbol-function :add) #'+
(symbol-function :subtract) #'-
(symbol-function :multiply) #'*)
(unwind-protect
(reduce
(lambda (result op-value)
(funcall (car op-value) result (cadr op-value)))
instructions
:initial-value 0)
(fmakunbound :add)
(fmakunbound :subtract)
(fmakunbound :multiply)))Re: A Road to Lisp: Which Lisp
#174Earlier quoted context omitted.
I've got really mixed feelings about Clojure. Like when I read Graham's book I went through a phase of "he wouldn't be fighting with nconc if he was using Clojure!" I find some algorithms to be easy and fun to write using persistent data structures and others maddening though if I did it more I'd get better at it. zippers are weirdly unergonomic because of some little bad choices. I badly wanted to do a project with…
I'm a longtime emacs head and partisan ... but I learned vi to compose emails in the Berkeley computer lab in 1989 and somehow have never forgotten vi key commands ever since. Emacs is my preferred sw dev editor for most things but I feel like not knowing vi is almost professional negligence if you are on the terminal.
How the heck anyone doing anything remotely related to programming can't be familiar with vim navigation? And if they're familiar what does "meh" supposed to mean? It's like having an "opinion" about where the Tab key sits on the keyboard: "I hate Tab, it was a stupid idea to put it on the left side..."
Re: A Road to Lisp: Which Lisp
#175Earlier quoted context omitted.
Did you know CL allows keywords to be function names? [1]> (setf (symbol-function :add) (function +)) # [2]> (setf (symbol-function :subtract) (function -)) # [3]> (setf (symbol-function :multiply) (function *)) # [4]> (setf (symbol-function :divide) (function /)) # [5]> (reduce (lambda (x y) (funcall (car y) x (cadr y))) '((:add 5) (:multiply 3) (:subtract 4)) :initial-value 0) 11 This is actually a small benefit of…
Huh, I guess I "knew" since keywords are just regular symbols in the KEYWORD package in this situation, but it never occurred to me to do something that cursed. Very cool! But this made me realize there's no way in CL (even with PROGV shenanigans) to temporarily bind the function value of a symbol, unlike the variable one through a simple LET =( So this turns in this horrible (and incorrect, since this doesn't restor…
Pascal Costanza somehow implemented such a thing. See 2003 paper "Dynamically Scoped Functions as the Essence of AOP", a precursor to work on AspectL and ContextL.
https://dl.acm.org/doi/pdf/10.1145/944579.944587
Dynamically scoped functions are wrappers which indirect to lambdas bound to a special variable; i.e. this is boostrapped out of dynamic variable scope.
Re: A Road to Lisp: Which Lisp
#176Since a few folks here recommended Common Lisp to me as the language that would "tick all my boxes", I've been doing a deep dive. Right now, I'm working through SICP again with DrRacket. The first time I worked through it with MIT Scheme MANY years ago. It's shocking how much I've forgotten. What I like about this article is that it walks through the different "camps" of Lisp. Scheme is so intriguing to me because of…
Re: A Road to Lisp: Which Lisp
#177Earlier quoted context omitted.
You can directly call C++ as C++ , not via a C ABI.
> You can directly call C++ as C++, not via a C ABI. That's a unique definition of "native". It suggests that C is not a native language, which is going to be a hard thing to convince others of.
Re: A Road to Lisp: Which Lisp
#178Earlier quoted context omitted.
> You can directly call C++ as C++, not via a C ABI. That's a unique definition of "native". It suggests that C is not a native language, which is going to be a hard thing to convince others of.
I mean if you're going to be that pedantic, then Clojure is "native" since all Clojure functions "compile to machine code" via the JVM's JIT.
Re: A Road to Lisp: Which Lisp
#179Earlier quoted context omitted.
thanks.
The book takes you through simpler examples, but I found that the exercises did an excellent job of drilling a kind of recursive problem solving skill into your head. You represent the data in types, and then keep breaking the problem down into smaller functions until it is solved. It's almost magic. After being armed with this way of thinking (through lots of practice with the many exercises) I found that problems I…
you nailed it.
>then keep breaking the problem down into smaller functions until it is solved.
That technique definitely works. i have used it. so have tons of others.
it closely resembles the methods of structured programming and stepwise refinement.
Both those terms are probably there in Wikipedia, because they are notable, being well known. and check out niklaus wirth. ditto. turing prize winner or other major awardee. pascal. modula family languages. etc.
Re: A Road to Lisp: Which Lisp
#180Since a few folks here recommended Common Lisp to me as the language that would "tick all my boxes", I've been doing a deep dive. Right now, I'm working through SICP again with DrRacket. The first time I worked through it with MIT Scheme MANY years ago. It's shocking how much I've forgotten. What I like about this article is that it walks through the different "camps" of Lisp. Scheme is so intriguing to me because of…
I also have started doing SICP recently with Racket and `#lang sicp`. Sometimes I skip some exercises and will come back to them at a later time. It allows me to choose when to advance reading the text or make the exercises. So far in section 3.1.3. Discovered MIT Scheme in 1996 at university, got plenty of scheme books for years including SICP, and each year telling myself that I should do this classic. I am reading…