The Land of Lisp
81–90 of 146 posts
Re: The Land of Lisp
#82When I discovered lisp several years ago, it was indeed the textbook moment of enlightenment that you've heard about. This book was a part of that introduction for me (along with Practical Common Lisp). After working in C-like languages, I had no idea that programming could work this way as in lisp, the idea of code and data being inseparable, I even had dreams at night about run-time data structures getting expresse…
Common Lisp: (defmethod collide ((object1 space-ship) (object2 rocket)) "Inline documentation for this method..." (the debris (create-debris-from space-ship)) SPACE-SHIP and ROCKET are types and classes. DEBRIS would also be a type and a class. Use DEFTYPE, DEFCLASS, DEFSTRUCT, ... to define new types. Use CHECK-TYPE and ASSERT to have runtime checks, integrated with the condition system.
Re: The Land of Lisp
#83I've learned LISP and Scheme, gained some useful insights, used them on a few random projects, and then dropped them. I recommend learning them, but then switching to something like Reason / OCaml / F# / Haskell.
Re: The Land of Lisp
#84Re: The Land of Lisp
#85Re: The Land of Lisp
#86Re: The Land of Lisp
#87Earlier quoted context omitted.
Common Lisp: (defmethod collide ((object1 space-ship) (object2 rocket)) "Inline documentation for this method..." (the debris (create-debris-from space-ship)) SPACE-SHIP and ROCKET are types and classes. DEBRIS would also be a type and a class. Use DEFTYPE, DEFCLASS, DEFSTRUCT, ... to define new types. Use CHECK-TYPE and ASSERT to have runtime checks, integrated with the condition system.
Well I can do runtime checks just as easily in Clojure, but I'm really talking about compile time checks.
> Without type annotations and checked structured data for everything, it can also be hard to remember what a function does, or what its variables represent, when you read the code later.
I showed you how to annotate types in Common Lisp.
You also said:
> The other feature that occurs more often is in-line documentation.
Which exists in Lisp since 80s or earlier.
> but I'm really talking about compile time checks.
(declaim (ftype (function (integer string) cons)
foo))
(defun foo (a b)
(list a b))
(defun bar (a) (foo "baz" a))
Running the SBCL compiler: ; file: /private/tmp/test.lisp
; in: DEFUN BAR
; (FOO "baz" A)
;
; note: deleting unreachable code
;
; caught WARNING:
; Constant "baz" conflicts with its asserted type INTEGER.
; See also:
; The SBCL Manual, Node "Handling of Types"
At least some type checks are done at compile time...Re: The Land of Lisp
#88Previously it was a different one.
Re: The Land of Lisp
#89Earlier quoted context omitted.
Common Lisp: (defmethod collide ((object1 space-ship) (object2 rocket)) "Inline documentation for this method..." (the debris (create-debris-from space-ship)) SPACE-SHIP and ROCKET are types and classes. DEBRIS would also be a type and a class. Use DEFTYPE, DEFCLASS, DEFSTRUCT, ... to define new types. Use CHECK-TYPE and ASSERT to have runtime checks, integrated with the condition system.
Well I can do runtime checks just as easily in Clojure, but I'm really talking about compile time checks.
Take a look at this: http://ahungry.com/blog/2015-07-10-Type-Safety-and-Lack-Ther...
It shows you a 9-lines macro for CL, that allows you to declare types in a way resembling Haskell, and having the compiler do the static checks.
Very nice.
Another example is here: https://news.ycombinator.com/item?id=8598149
Re: The Land of Lisp
#90This book is destined to be a classic programming book, just as "The C programming language", "The Little Schemer" or "Operating systems: Design and implementation". I would really like to meet Conrad Barski and give him a great hug. And invite him a good beer. Be sure to read the comic that is on the bottom of the page!! Now, to be honest, a quicker or more practical introduction to Lisp would be the "Practical Comm…
That comic by Dr. Barski tears me up every time! Just to test, I went and read the comic again and I cried, again!
I have met Dr. Barski personally at a Clojure conference many years ago and I still remember him as an extremely kind and knowledgeable person.
Thank you for the Land of Lisp, Dr. Barski! Some day, we will be able to assemble our guilds and beat the Insectoids for good. Until then,long live language du jour!