[plt-scheme] vectors and threads

From: Danny Yoo (dyoo at hkn.eecs.berkeley.edu)
Date: Thu Dec 15 21:07:53 EST 2005

> Are vectors thread safe in mzscheme?

Hi Hans,

According to Section 7.1 in the MzScheme language manual, all the
primitives should be kill-safe and suspend-safe:


The vector methods should all be primitive.  Let's check that!

(require (lib "string.ss"))
(require (lib "list.ss"))

;; Returns a true value if a is a substring of b
(define (substring? a b)
  (regexp-match (regexp-quote a) b))

;; List of all the built in functions with "vector" in their names
(define vector-builtins
  ;; Make sure we're looking at a clean namespace.  (We don't want to
  ;; include ourselves!  *grin*)
  (parameterize ((current-namespace (make-namespace)))
    (map namespace-variable-value
         (filter (lambda (sym)
                   (substring? "vector" (symbol->string sym)))

(define vector-non-primitives
   (filter (lambda (f) (not (primitive? f))) vector-builtins))

Let's see what comes out:

> vector-non-primitives

Ok, looks like the vector-functions are all primitives.

Hope this helps!

Posted on the users mailing list.