understanding structures :read-only slot-option 
Author Message
 understanding structures :read-only slot-option

I want to create a structure containing both a vector and a hash-table:

(defstruct (enumeration
            (:constructor %make-enumeration (hash))
            (:print-function (lambda (enum stream depth)
                               (declare (ignore depth))
                               (format stream "#<ENUMERATION ~S>"
                                       (enumeration-vector enum)))))
  "Contains enumerated objects [0.. ] and maintains the numbering."
  (hash   (make-hash-table)
          :type hash-table)
  (vector (make-array 0 :adjustable t :fill-pointer t)
          :type vector))

Is it right that the hash-table-slot could be marked read-only because
I'll only be adding (or removing) elements to (or from) the hash-table?

Is it possible to do the same with the vector, even if I use
vector-push-extend (because the vector is not of fixed size) as in:
(vector-push-extend element (enumeration-vector enumeration))? I guess
that vector-push-extend being a function, it will only modify the
object (the vector), not the slot binding.

Thanks for enlightening me,
        Joerg Hoehle.



Tue, 06 Aug 1996 23:22:58 GMT  
 understanding structures :read-only slot-option

Quote:
>I want to create a structure containing both a vector and a hash-table:
...
>Is it right that the hash-table-slot could be marked read-only because
>I'll only be adding (or removing) elements to (or from) the hash-table?

Yes.  :READ-ONLY only affects whether you can modify the slot itself.  It
doesn't declare the object referenced by the slot to be constant.  If
you'll never be doing (setf (<accessor> <object>) ...), or anything that
macroexpands into it, then you can make it read-only.
--
Barry Margolin
System Manager, Thinking Machines Corp.




Fri, 09 Aug 1996 09:13:48 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Structure slot-init accessing previous slot

2. Structure slots (surely not MOP?)

3. defining setf method for storing in structure slot

4. OO-Browser does not understand Lisp defstruct options?

5. RECURSIVE-P option to READ, READ-CHAR, etc?

6. Reading the PC-Card Slots

7. Slot-1 advocates -- read this

8. Slots of a slot definition metaobject

9. CLOS: read only slots?

10. Option Structures in CFD 3.1

11. reading and understanding graphics files

12. understanding 'property' / making value read-only

 

 
Powered by phpBB® Forum Software