[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Syntax of make-record :pattern



Karsten Poeck writes:

> Could somebody give an example of the use of
> (make-record :pattern)
> In the pre 2.0 times the pattern record was a variant that allowed us to
> specify the bytes as in
> (make-record :pattern
>                 :b0 15  :b1 15  :b2 15  :b3 15
>                 :b4 240 :b5 240 :b6 240 :b7 240)
> With the 2.0 definition Mcl doesn't like that anymore and we have to use
> something like
> (make-record :pattern :array ....)
> but I don't know how to use that.

I reported this problem to info-bug some time ago.  The response
was that the "old" definition was non-standard. You can still use
the "old" definition with the variants.

You are right that the record definition changed. I don't know
how to access the fields in the "new" record. It is easy
to "reinstall" the old definition and make it work.

;; here's the NEW code from library:interfaces;quickdraw.lisp
(defrecord (Pattern :handle) (array (array :unsigned-byte 8)))

;; Here's the code from Records.lisp (now obsolete)
; bill 08/02/91   Add variant to PATTERN record that agress with 
interfaces;quickdraw.lisp

? (load "ccl:library;records.lisp")

;Warning: The file #P"Palm:MCL 2.0:library:records.lisp" is now obsolete; 
;         all record definitions are now autoloaded 
;         from the files in the "CCL:interfaces;" directory.
; While executing: LOAD-FROM-STREAM

; now just evaluate the :pattern record definition in records.lisp 
? (defrecord pattern 
    (variant ((w0 integer)
              (w1 integer)
              (w2 integer)
              (w3 integer))
             ((b0 byte)
              (b1 byte)
              (b2 byte)
              (b3 byte)
              (b4 byte)
              (b5 byte)
              (b6 byte)
              (b7 byte))
             ((bytes (array byte 8)))
             ((array (array :unsigned-byte 8)))))

;Warning:  CCL::RECORD :PATTERN previously defined in: 
ccl:interfaces;QUICKDRAW.lisp
;                  is now being redefined in: Palm:Desktop Folder:test.lisp
;         
; While executing: RECORD-SOURCE-FILE
:PATTERN

; now use the new record definition
? (setq that *gray-pattern*)
#<A Mac Non-zone Pointer #x6A9830>
? (print-record that :pattern)
#<Record :PATTERN :W0 -21931 :W1 -21931 :W2 -21931 :W3 -21931 :B7 85>
? (list (rref that :pattern.b0)
      (rref that :pattern.b1)
      (rref that :pattern.b2)
      (rref that :pattern.b3)
      (rref that :pattern.b4)
      (rref that :pattern.b5)
      (rref that :pattern.b6)
      (rref that :pattern.b7))
(170 85 170 85 170 85 170 85)

? (setq that (make-record :pattern
                 :b0 15  :b1 15  :b2 15  :b3 15
                 :b4 240 :b5 240 :b6 240 :b7 240))

#<A Mac Zone Pointer Size 8 #x131588>
? (list (rref that :pattern.b0)
      (rref that :pattern.b1)
      (rref that :pattern.b2)
      (rref that :pattern.b3)
      (rref that :pattern.b4)
      (rref that :pattern.b5)
      (rref that :pattern.b6)
      (rref that :pattern.b7))
(15 15 15 15 240 240 240 240)
? (dispose-record that :pattern)