3 ms·
I think that the author needs to learn about association lists. The constructor (define point '((x 1) (y 2) (z 3))) is as clear as any other language. Granted
by thisrod 9y ago
I think that the author needs to learn about association lists. The constructor (define point '((x 1) (y 2) (z 3))) is as clear as any other language. Granted, (assoc 'x point) is a bit more verbose than point.x, but you could extend Lisp with the syntax ('x point) if it matters. Does Arc do that?
- kbp 9y ago> I think that the author needs to learn about association lists. The constructor (define point '((x 1) (y 2) (z 3))) is as clear as any other language. Granted, (assoc 'x point) is a bit more verbose than point.x, but you could extend Lisp with the syntax ('x point) if it matters. Does Arc do that? As a minor point, the values in an alist are just the cdrs of each pair, so your point alist would be written '((x . 1) (y . 2) (z . 3)); yours has each value being a one-element list. But anyway, if that level of verbosity doesn't bother you, you could just use a struct like the article mentions and write: (defstruct point x y z) (defvar *point* (make-point :x 1 :y 2 :z 3)) (format t "~&x is ~a" (point-x *point*)) The author claims that this is too verbose and therefore no one uses structs or classes, which is not at all true in my experience, and it doesn't look that verbose to me either. If the point- prefix really bothers you, you can say (defstruct (point (:conc-name)) x y z) and then the accessors will be defined without it.