
Response to: Problems with Lisp - mqt
http://gnuvince.wordpress.com/2009/01/25/response-to-problems-with-lisp/
======
gruseom
I lurched to a halt at this:

    
    
      # Would you rather type this?
      oldest({"Vincent": 25, "Lincoln": 200})
    
      # Or this?
      (let ((ages (make-hash-table :test 'equal)))
        (setf (gethash "Vincent" ages) 25)
        (setf (gethash "Lincoln" ages) 200)
        (oldest age))
    

No one who understood CL would ever write the latter. They would write:

    
    
      '((Vincent . 25) (Lincoln . 200))
    

... which, yes, I would rather type.

It would be surprising if during the 50-year evolution of a language known for
code ≈ data, people hadn't thought of a notation for literal key-value pairs.

~~~
gecko
That's somewhat begging the question, though. Assoc lists aren't hash tables,
do not have the performance characters of hash tables, and excepting simple
circumstances, cannot be used like hash tables. Now, many Lisps and Schemes
have something similar to

    
    
        (hash-from-list '((Vincent . 25) (Lincoln . 200)))
    

but that's still a far cry from having a literal hash table syntax à la
Clojure or similar languages.

~~~
twopoint718
It's not that tough to make a literal syntax for hash tables with a simple
reader macro. This may not be the best way to do it, I'm rather new to lisp,
but it only took me about 5 min. (and a peek at "ANSI Common Lisp" 14.3,
thanks, PG!):

    
    
        (defun ins-hash (h vals)
          (if (oddp (length vals))
              nil
              (if (not (null vals))
                  (progn
                    (setf (gethash (first vals) h) (second vals))
                    (ins-hash h (cddr vals)))
                  h)))
    
        (set-macro-character #\} (get-macro-character #\)))
    
        (set-dispatch-macro-character #\# #\{
          #'(lambda (stream char1 char2)
              (let ((items (read-delimited-list #\} stream t)))
                (ins-hash (make-hash-table) items))))
    
        CL-USER> (gethash :b #{:a 1 :b 2 :c 3})
        2
        T

------
anamax
The problem with all of the syntax arguments is that they give away something
significant to get something almost meaningless.

Accessible syntax is important. However, accessible doesn't mean/imply/require
terse or specialized. Moreover, accessibility by programs is also important.

I know some amazing programmers but I've never met one who could write code,
let alone good code, faster than a code generator.

