Live data from Hacker News

Land of Lisp (2010)

landoflisp.com

71–80 of 84 posts

Re: Land of Lisp (2010)

#71
post #48

Earlier quoted context omitted.

The way I do it, is that in my editor, I can type: '(some data|) Where | is my cursor. And then I have a keybinding that moves my cursor to the front and wraps around like so: (| '(some data)) So I can type the next thing: (get-string| '(some data)) Press it again: (| (get-string '(some-data))) And so on. That way, even though the code is visually nested, I can write it in logical order from what eval first to what e…

This is just what I've been looking for! I've been searching for this and see there are commands for navigating s expressions but I haven't found this example. Is this a built-in command? Is there name for this action?

There are some built-in commands in Emacs for navigating, cutting and transposing s-exps, but what you want is probably a step further - a package like Paredit[0], that gives you much more sexp-specific actions, and automatically keeps parens balanced for you. See animated examples at [1] and a cheat sheet at [2].

There isn't, as far as I know, a default keybinding for what GP did - navigate up the SEXP, wrap in parens and place point before the inner SEXP. You can get very close to it with two steps: paredit-backward-up [C-M-u] and paredit-wrap-round [M-(], though it gets confused by the hanging quote a bit. To demonstrate on GP's example:

  '(some data|)
  '|(some data)    ; after C-M-u
  '(|(some data))  ; after M-(
So the quote is in a wrong place. You could probably whip a command doing OP's thing that calls paredit-backward-up and paredit-wrap-round, with a conditional that backs up a few chars if it detects a piece of syntactic sugar attached to the SEXP (quote, quasiquote, comma, reader macro invocation). Somebody has likely already done it, or maybe there is a less known Paredit command for that - I don't know. If anyone does, please chime in.

Myself, I mostly use wrapping, barfing and slurping.

--

[0] - Available in Emacs' package manager on MELPA, or here: https://github.com/emacsmirror/paredit.

[1] - http://danmidwood.com/content/2014/11/21/animated-paredit.ht...

[2] - https://github.com/joelittlejohn/paredit-cheatsheet

Re: Land of Lisp (2010)

#72
post #26

Earlier quoted context omitted.

I nearly started working through that, would you mind sharing why you think it is a bad book? thx

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

Re: Land of Lisp (2010)

#73

This book is well worn, dog eared, and on my home office book shelf. While many people criticize it, for legitimate reasons, it is still a fun and wonderful journey through Common Lisp. I wish more books were written in this irreverent and whimsical style. If however you want a more traditional and "from zero" introduction to Lisp, then "Common LISP - A Gentle Introduction to Symbolic Computation"[0] may be better. I…

If you like this sort of thing, here are some others in a similar humorous style for other languages. 1. Kaufman, Roger. A FORTRAN Coloring Book (probably the first funny programming book -- from 1978). 2. Lipovača, Miran. Learn You A Haskell for Great Good. 3. Hebert, Fred. Learn You Some Erlang for Great Good (inspired by the Haskell book). 4. Felleisen, Matthias. Realm of Racket (basically Land of Lisp for Racket.…

Only from skimming the first few pages of "Why's (poignant) guide to Ruby" I wanted to learn Ruby.

I didn't checked recently, but I found bizarre (maybe not the right word) how the author one day decided to disappear and nuke his Internet presence.

https://poignant.guide/

Re: Land of Lisp (2010)

#74
post #18

Author of LOL here, if there are any questions!

Did you draw the pictures yourself? I really like the long final comic story, and several times thought about making some roguelike ascii game with this background (choosing a guild with specific skills, killings various kinds of bugs, etc.), but I am too lazy for having actually written it... Thank you for that!

Yes, drew everything myself, took years of my free time given the size of the book :)

Re: Land of Lisp (2010)

#75
post #36
post #18

Author of LOL here, if there are any questions!

Are you plan to write any new Lisp books? Or any book for that matter? Would be interested in reading anything you write :)

I also co-wrote "Bitcoin for the Befuddled" and participated in "Realm of Racket". I am sort of enamoured by other media now (video, animation, interactive web stuff) and if I do anything else it will be in that vein in the future (though I have struggled with akrasia on that front)

Re: Land of Lisp (2010)

#76

Earlier quoted context omitted.

If you like this sort of thing, here are some others in a similar humorous style for other languages. 1. Kaufman, Roger. A FORTRAN Coloring Book (probably the first funny programming book -- from 1978). 2. Lipovača, Miran. Learn You A Haskell for Great Good. 3. Hebert, Fred. Learn You Some Erlang for Great Good (inspired by the Haskell book). 4. Felleisen, Matthias. Realm of Racket (basically Land of Lisp for Racket.…

Only from skimming the first few pages of "Why's (poignant) guide to Ruby" I wanted to learn Ruby. I didn't checked recently, but I found bizarre (maybe not the right word) how the author one day decided to disappear and nuke his Internet presence. https://poignant.guide/

I love this guide! A friend showed it to me and I still quote lines from it often. I like the bit about "our own recliners", I tell my friend that someday him and I will have our own recliners. Another line I vaguely remember is when he's made a backpack for a bug out of a leaf. I think he puts a skittle and a battery in there and then says "that should last him". The writing style is great.

Re: Land of Lisp (2010)

#77

Earlier quoted context omitted.

If you like this sort of thing, here are some others in a similar humorous style for other languages. 1. Kaufman, Roger. A FORTRAN Coloring Book (probably the first funny programming book -- from 1978). 2. Lipovača, Miran. Learn You A Haskell for Great Good. 3. Hebert, Fred. Learn You Some Erlang for Great Good (inspired by the Haskell book). 4. Felleisen, Matthias. Realm of Racket (basically Land of Lisp for Racket.…

Only from skimming the first few pages of "Why's (poignant) guide to Ruby" I wanted to learn Ruby. I didn't checked recently, but I found bizarre (maybe not the right word) how the author one day decided to disappear and nuke his Internet presence. https://poignant.guide/

Yes, that was interesting. I read about it at the time (I was doing Ruby around then). Another one on the same lines was Mark Pilgrim (author of Dive into Python and similarly-named books for Python 3 and HTML 5, IIRC).

Re: Land of Lisp (2010)

#78
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.

That's the same as:

    (chain somedata (tostring) (trim))
It's a macro away in Lisp. But I would not use it much, since it kind of defeats the advantage of using nested expressions -> they are actually nested.

Re: Land of Lisp (2010)

#79
post #27
post #21

Earlier quoted context omitted.

What do you think about making a second edition?

I would say "Realm of Racket" is really the second edition to "Land of Lisp"- The fact is that most lisp developers now use either Racket Scheme or Clojure, so those are really the only markets that could support a rework of LOL in 2019. I've tried a couple of times in the past to work with someone on a Clojure port, but just haven't been able to make the coauthor+publisher work out right to get it launched.

I'll have to check it out. I'm surprised about your impression of where most lisp developers are in 2019 vs 2010 -- from my (admittedly still rather outsider) perspective the CL ecosystem looks significantly healthier in 2019 than in 2010. Clojure[Script] remains dominant but has lost a lot of steam, Racket took some high-profile Lispers but still doesn't have the production success stories that both CL and Clojure have and language progress is likely to be stalled a while as the transition to a Chez core continues, and CL usage and useful libraries have despite it all grown. The main IRC channel is active, there's a C++ integration story (Clasp), more frequent CL-related HN submissions, the European Lisp Symposium this year had a lot of new first-time attendees, and new books with an emphasis on helping production programmers (e.g. Common Lisp Recipes) were published.

Re: Land of Lisp (2010)

#80
post #48

Earlier quoted context omitted.

Hey Dr Barski. I'm actually reading your book right now. I do have a question. How do you write Lisp effectively? And by that I mean, Lisp seems to be written from the inside out due to the nested lists. Is there something that makes it more natural to write: (trim-string (get-string '(some data))) Or do you need to know that you're going to call trim before you get the string? Hope that makes sense.

The way I do it, is that in my editor, I can type: '(some data|) Where | is my cursor. And then I have a keybinding that moves my cursor to the front and wraps around like so: (| '(some data)) So I can type the next thing: (get-string| '(some data)) Press it again: (| (get-string '(some-data))) And so on. That way, even though the code is visually nested, I can write it in logical order from what eval first to what e…

For anyone stubborn enough to want to do this with Vim, I've come up with this.

  function NestExpression()
      " Get end paren pos
      " Returns [0, 0] if not in parens.
      let save_cursor = getpos('.')

      " If line not set to zero, append
      let end_paren_pos = searchpairpos('(', '', ')')
      if end_paren_pos[0] > 0
          execute "normal! a)"
      else
          " We're not in a set of parentheses
          return
      endif

      " Return to the inside of the parentheses
      call setpos('.', save_cursor)

      " If line not set to zero, start insert
      " mode, prepend and move cursor left
      let end_paren_pos = searchpairpos('(', '', ')', 'b')
      if end_paren_pos[0] > 0
          call feedkeys("i( \")
      endif
  endfunction

  nmap fj :call NestExpression()
Post reply on HN