Beginner question

From: Yoel Jacobsen (yoel_at_emet.co.il)
Date: 01/31/05


Date: Mon, 31 Jan 2005 11:19:43 +0200

I'm experimenting CL by attempting to write some basic programs.

I'm trying to write an /etc/passwd to LDIF converter and I'm stuck - I
can't figure out from CLISP errors what is wrong. Here is my code:

(require 'split-sequence)

(defmacro list-to-plist (plist pos-list id-list field-list)
   `(progn ,@(map 'list
        #'(lambda (id pos)
            `(setf (getf ,id ,id-list) (elt ,field-list ,pos)))
        plist pos-list)))

(defun pline-to-plist (line)
   "convert a passwd line to a plist"
   (let ((fields (split-sequence:split-sequence #\: line))
                 (entry nil))
     (list-to-plist
      '(:login :passwd :uid :gid :group :home :shell)
      '(0 1 2 3 4 5 6 7)
      entry fields)
     entry))

(format t "~S~%" (pline-to-plist
"news:x:9:13:news:/usr/lib/news:/bin/false"))

I tried to use a macro to shorten the following pattern:
(SETF (GETF :LOGIN ENTRY) (ELT FIELDS 0))
(SETF (GETF :PASSWD ENTRY) (ELT FIELDS 1))
(SETF (GETF :UID ENTRY) (ELT FIELDS 2))
(SETF (GETF :GID ENTRY) (ELT FIELDS 3))
(SETF (GETF :GROUP ENTRY) (ELT FIELDS 4))
(SETF (GETF :HOME ENTRY) (ELT FIELDS 5))
(SETF (GETF :SHELL ENTRY) (ELT FIELDS 6))

Now, I get diffetent errors:
Inside SLIME -
        FUNCALL: undefined function NIL
           [Condition of type SYSTEM::SIMPLE-UNDEFINED-FUNCTION]
When evaluating directly with CLISP:
        *** - SYSTEM::%EXPAND-FORM: invalid form (0 1 2 3 4 5 6 7)

Where did I wrong?