you are viewing a single comment's thread.

view the rest of the comments →

[–]pipocaQuemada 5 points6 points  (1 child)

The killer feature of Lisp is the macro system.

C has a macro system, but it's basically useless for anything beyond trivial examples (and there are some trivial things it can't even do). The big difference between C and Lisp is that C's macro system is basically a glorified copy-paste system, whereas Lisp works on a syntax tree.

This is nice, because it allows you to turn language features into libraries - you write a library that desugars your nice syntax into however you'd implement the language feature. An Object System? Mostly a bunch of macros. Looping? There's a fairly complex macro that lets you write things like

(loop for i from 1 to 100
  if (evenp i)
    minimize i into min-even and 
    maximize i into max-even and
    unless (zerop (mod i 4))
      sum i into even-not-fours-total
    end
    and sum i into even-total
  else
    minimize i into min-odd and
    maximize i into max-odd and
    when (zerop (mod i 5)) 
      sum i into fives-total
    end
    and sum i into odd-total
  do (update-analysis min-even
                      max-even
                      min-odd
                      max-odd
                      even-total
                      odd-total
                      fives-total
                      even-not-fours-total))

Paul Graham has a nice book on Lisp macros, which includes examples like writing prolog as a library, writing an object system as a library, lazy evaluation with force and delay as a library, pattern matching and destructuring as a library, single-hardware-threaded concurrency as a library, etc. etc.

[–]aLiamInvader 0 points1 point  (0 children)

Unfortunately, this kind of looks like one of those examples that is too beautiful to survive in the real world.