Live data from Hacker News

Land of Lisp (2010)

landoflisp.com

81–84 of 84 posts

Re: Land of Lisp (2010)

#81
post #47

Earlier quoted context omitted.

how do you write it in other languages? sin(cos(10.4)); or v = 10.4; c = cos(v); s = sin(c); in Lisp one might write: (let* ((v 10.4) (c (cos v))) (sin c)) really old style: (prog (v c s) (setq v 10.4) (setq c (cos v)) (setq s (sin c)) s)

Thanks for the reply! I'd go the first route unless method chaining was available. SomeData.ToString().Trim() I would like to write idiomatic Lisp code and it's getting easier to read the nested expressions but it breaks the flow to leave the expression and wrap it. Another user mentioned using a command with Emacs to escape the expression and auto wrap it. That might be what I'm looking for.

  This is the TXR Lisp interactive listener of TXR 215.
  Quit with :quit or Ctrl-D on empty line. Ctrl-X ? for 
  cheatsheet.
  1> [chain tostring trim-str]
  #
  2> [*1 3.4]
  "3.4"
  3> [[chain tostring trim-str] 3.4]
  "3.4"
No ready example of a datatype that requires trimming after a string conversion! We'd have to write one:

  4> (defstruct foo nil
       (:method print (me stream pretty-p)
         (put-string "foo " stream)))
  #
  5> (tostring (new foo))
  "foo "
Okay we are in business:

  6> [[chain tostring trim-str] (new foo)]
  "foo"
Method chaining syntax is possible, but with actual methods only. Most library functions aren't methods; you have to roll your own:

  1> (defstruct accum nil
       (val 0)
       (:method inc (me : (delta 1))
         (inc me.val delta)
         me)
       (:method mul (me : (factor 2))
         (upd me.val (* factor))
         me))
  #
  2> (new accum).(inc).(inc).(mul 3)
  #S(accum val 6)
  3> (new accum).(inc).(inc).(mul 3).val
  6
Support for idiom isn't the result of a conscious design decision; it just arises naturally when you have this sort of postfix syntax.

TXR's dot syntax is a very straightforward sugar for Lisp structure. Basically x.y.z == (qref x y z). Whitespace is not allowed around the dot. Numbers are also not allowed: 3.4 is a floating-point constant and a.3 or 3.a are invalid. If the leading element is missing, then it's the uref (unbound ref) operator: .y.z == (uref y z). This compiles to a function resembling (lambda (obj) obj.y.z).

Re: Land of Lisp (2010)

#82

Earlier quoted context omitted.

> is there such a thing as a bad Lisp book? Yes, there exists a certain a really awful book from the 1980's about making your own Lisp in C, which has recently been reprinted in essentially its original form.

Oh that sounds exciting, what's it called?

It is called Interpreting Lisp by G. Knott.

Reddit discussion: https://www.reddit.com/r/lisp/comments/6qc61v/second_edition...

Not to be confused with other books from the 1980s about doing Lisp in C, like Lisp: A Portable Implementation by S. Hekmatpour.

Re: Land of Lisp (2010)

#83
post #72

Earlier quoted context omitted.

I’m pretty sure it’s because the lisp that book makes isn’t an exact lisp; There are many features lacking and some fundamental concepts are wrongly implemented; However for developing C skills, it’s pretty good. Wouldn’t recommend learning Lisp with that though.

oh you're correct it is meant to develop C skills not learn Lisp

The 900-something lines of C code documented by the book Interpreting Lisp, which can now be found on Github, is not something I would recommend for teaching C beginners.

From a best practices point of view, it is pretty awful.

https://github.com/Apress/interpreting-lisp

Re: Land of Lisp (2010)

#84
post #54

Earlier quoted context omitted.

Hmmm I think I remember a few failed jokes but I found the actual coverage of the language pretty good, wdyt? I guess for a book like this you are not really looking for a comedy best seller, no? :-)

I guess the thing is that when an attempt at humor fails, which is obviously subjective, it starts to distract from the content.

I agree it is subjective. I actually open Clojure for The Brave and True book from now and then just because I find so much of it truly hilarious. The hilarity is what really helped me get Clojure. I also like the Land of Lisp and find it funny as well.
Post reply on HN