[CM] metadata on vectors?

bil at ccrma.Stanford.EDU bil at ccrma.Stanford.EDU
Mon Jul 26 12:17:38 PDT 2021


Here's one way to do that in scheme:

(require mockery.scm)

(define (meta-vector v data)
   (openlet
    (sublet (*mock-vector* 'mock-vector-class)
      'value v
      'mock-type 'mock-vector?
      'meta-data data)))

(define v (meta-vector #(0 1 2) "hiho"))

(display (v 1))
1

(display (v 'meta-data))
hiho

(display v)
#(0 1 2)

(vector? v)
#t

heh heh -- the last is a lie of course; it's actually
a let trying to masquerade as a vector.  mockery.scm
defines several such "mock data" types.



More information about the Cmdist mailing list