Live data from Hacker News

The Nature of Lisp

defmacro.org

21–30 of 82 posts

Re: The Nature of Lisp

#21
post #8
post #5

Earlier quoted context omitted.

Common Lisp != Lisp. You mean Common Lisp, Lisp is the family of languages (which also includes the Scheme sub-family, Racket, Clojure, Arc, Kernel…).

Its disingenuous to call scheme and racket lisps. They have parenthesis and first class functions but the similarities stop there. So yes I equate Lisp with common lisp. I didn't read the entire article (far too long) but he does mention 'defmacro' which is in Common Lisp.

[deleted]

Re: The Nature of Lisp

#22
post #8
post #5

Earlier quoted context omitted.

Common Lisp != Lisp. You mean Common Lisp, Lisp is the family of languages (which also includes the Scheme sub-family, Racket, Clojure, Arc, Kernel…).

Its disingenuous to call scheme and racket lisps. They have parenthesis and first class functions but the similarities stop there. So yes I equate Lisp with common lisp. I didn't read the entire article (far too long) but he does mention 'defmacro' which is in Common Lisp.

So, homoiconicity is a trifling, meaningless similarity?

"Sure, it may be homoiconic, use prefix notation, have first-class functions (in additional to all the other usual functional paradigms that aren't unique to lisps) but it's not a lisp."

Big ok to that one. This must be pedantry of the highest caliber, not ignorance.

Re: The Nature of Lisp

#23
post #4
post #2

I found that a rather good introduction to code as data, but I am not sure whether I am supposed to have been hit by the enlightenment he describes… :-)

Yes, for me the first time I read about the lisp syntax I was thinking: "oh cool, it makes (+ 2 2) exactly equivalent to the syntaxic tree + / \ 2 2 " But I don't find it particularly enlightening and I still don't see what cool stuff you can do with macros that you can't do elsewhere.

If you've ever used C#, imaging being able to implement LINQ in pure C# (as in, it's not part of the language, but the language itself gives you the ability to add it with the exact same syntax as it exists as part of the language). That is what macros give you. You can extend the language's syntax to your liking.

If you haven't used LINQ, then I'd have a hard time thinking of another example, since most languages have fairly uniform syntax.

Re: The Nature of Lisp

#24
post #5
post #3

To understand Lisp is to understand interpreters. With that understanding you can create domain specific languages which is extremely powerful. But I wouldn't recommend using Lisp itself.. macros in particular are unhygienic.

Common Lisp != Lisp. You mean Common Lisp, Lisp is the family of languages (which also includes the Scheme sub-family, Racket, Clojure, Arc, Kernel…).

You are right, but I disagree. I almost always call "Common Lisp" "Lisp." Scheme is Scheme, Clojure is Clojure, etc etc. I don't care about the family vs language distinction. I think it hurts Common Lisp's adoption. I'd sooner call Common Lisp, Scheme, Clojure, etc part of the "Lisp family" instead of just "Lisp," and leave "Lisp" to mean "Common Lisp."

Re: The Nature of Lisp

#25
post #8

Earlier quoted context omitted.

Its disingenuous to call scheme and racket lisps. They have parenthesis and first class functions but the similarities stop there. So yes I equate Lisp with common lisp. I didn't read the entire article (far too long) but he does mention 'defmacro' which is in Common Lisp.

So, homoiconicity is a trifling, meaningless similarity? "Sure, it may be homoiconic, use prefix notation, have first-class functions (in additional to all the other usual functional paradigms that aren't unique to lisps) but it's not a lisp." Big ok to that one. This must be pedantry of the highest caliber, not ignorance.

They are not homoiconic. The underlying datastructure for many schemes, and racket, is not a list. It is a syntax object. Of course you can still do metaprogramming with syntax objects but I wouldn't call it the same thing.

Re: The Nature of Lisp

#27
post #12

Earlier quoted context omitted.

Macros extend the power of the language way beyond its core primitives. For instance, I wrote a macro, TEMPORARY-ASSIGN. I use it like this: (TEMPORARY-ASSIGN ((traversing obj) true) ... do stuff ...) In Python, the equivalent code would be. old_trav = obj.traversing obj.traversing = True try: ... do stuff... finally: obj.traversing = old_trav There's no way to abstract out that pattern in Python. Every time you want…

I think I don't understand what your macro does, because the Python code is easily abstractable with a context manager: from contextlib import contextmanager @contextmanager def traverse(obj, attr, val): cached = getattr(obj, attr) setattr(obj, attr, val) yield setattr(obj, attr, cached) with traverse(obj, "traversing", True): # ... do stuff ... Could you explain what your example does that I've missed?

You're right that his example is possible in Python, but that's only because with happens to be part of the language. If it were not, you couldn't write my_with in Python code alone.

Meaning that the next time you need a feature that doesn't exist in Python, you can't add it.

You should cut these examples some slack; in reality, it's going to be hard to come up with a five line Python example that's ugly, because Python is quite a nice language, and most rough edges have been sanded down over the last 20 years.

That doesn't mean the techniques aren't useful in real world programs, like when you need to build a DSL - just that they're hard to explain in a dozen line HN comment.

Re: The Nature of Lisp

#28
post #12

Earlier quoted context omitted.

Macros extend the power of the language way beyond its core primitives. For instance, I wrote a macro, TEMPORARY-ASSIGN. I use it like this: (TEMPORARY-ASSIGN ((traversing obj) true) ... do stuff ...) In Python, the equivalent code would be. old_trav = obj.traversing obj.traversing = True try: ... do stuff... finally: obj.traversing = old_trav There's no way to abstract out that pattern in Python. Every time you want…

> There's no way to abstract out that pattern in Python. I'm sure there are macros that can't be abstracted out in Python but this isn't one of them: from contextlib import contextmanager @contextmanager def temp_assign(obj, attr, val): old_val = getattr(obj, attr) setattr(obj, attr, val) yield setattr(obj, attr, old_val) class X: pass x = X() x.a = 1 with temp_assign(x, "a", 2): print x.a # prints 2 print x.a # prin…

Cool, I didn't know that could be done. Can it work for global and local variables as well?

Re: The Nature of Lisp

#29
Part of the problem is that lisp evangelism sets itself up to fail. An instantaneous blinding moment of enlightenment, would you like fries with that? Haven't they heard that you shouldn't start a joke with "This is the most hilarious thing ever"?

I've been doing lisp for several years now. I've built several interpreters. I've never had the enlightenment he describes. The minor epiphanies have been on par with oo design and unit tests. I've travelled far over the months, but it's closer to grok than zen.

Re: The Nature of Lisp

#30
post #19
post #9

Very good article, though I doubt it'll convince the usual mass of unbelievers. (I love Lisp, for the record, though my primary exposure has been through Emacs Lisp - so shoot me). A really great book that helps you get appreciate the concepts in Lisp, without really talking about Lisp directly too much, is "Patterns of Software" by Peter Gabriel. http://amzn.to/TxDKGG I found it to be a very enlightening read. Defin…

Richard Gabriel. Though Peter Gabriel would be good too :)

Haha, oops! Too late to edit. Good catch. : )
Post reply on HN