Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In Common Lisp, all the data (such as primitive variable references, lists, arrays and hash tables) are mutable by default, so that nothing can prevent someone from changing the value of a variable, an element of a sequence or a field of a structure. </p> <p>However, if we're not talking about primitive data types but about user-defined data, that is about the CLOS structures and classes, their slots can be made read-only. For example, for structures:</p> <pre><code>(defstruct person (name nil :type string :read-only t) (age nil :type (integer 0 100))) (let ((john (make-person :name "John" :age 30))) (princ john) ;; * `age' is mutable: (incf (person-age john)) (princ john) ;; * `name' is not: ;; (setf (person-name john) "garbage name") ;; ^ you can't do this because the `defstruct' macro just don't emit SETFer ;; for the `name' slot as you made it read-only. ) </code></pre> <p>Classes provide even more access control for the slots (this is similar to the mechanism of the <code>const</code> qualifier in C, the difference is that in Common Lisp it is not a compile-time guarantee, but an exceptions which can be handled in a restarts), you can give them read and write, read-only, write-only, or no access.</p> <hr> <p>See the following links for more information:</p> <ul> <li><p><a href="http://psg.com/~dlamkins/sl/chapter07.html" rel="nofollow noreferrer">http://psg.com/~dlamkins/sl/chapter07.html</a></p></li> <li><p><a href="http://www.gigamonkeys.com/book/object-reorientation-classes.html" rel="nofollow noreferrer">http://www.gigamonkeys.com/book/object-reorientation-classes.html</a></p></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload