Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I get your point, but I'm not sure I share your cynicism. For instance, a "constant" container with mutable contents is the first example given in Practical Common Lisp [0]:

    (defvar *db* nil)

    (defun add-record (cd) (push cd *db*))
    (defun make-cd (title artist rating ripped)
      (list :title title :artist artist :rating rating :ripped ripped))

    (add-record (make-cd "Roses" "Kathy Mattea" 7 t))
If you're concerned about this kind of thing, we should be encouraging novice programmers to stop using language features they don't understand.

[0]: http://www.gigamonkeys.com/book/practical-a-simple-database....



My Lisp is a bit rusty, but I think actual constants are written +with-pluses+, whereas * the-stars * indicate global variables. And that database isn't just internally mutable, sometimes it's replaced completely [0]:

  (defun load-db (filename)
    (with-open-file (in filename)
      (with-standard-io-syntax
        (setf *db* (read in)))))
[0]: http://www.gigamonkeys.com/book/practical-a-simple-database....




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: