[racket-dev] pconvert and current-build-share-hook?

From: Danny Yoo (dyoo at cs.wpi.edu)
Date: Thu Nov 17 14:16:27 EST 2011

On Thu, Nov 17, 2011 at 1:43 PM, Robby Findler
<robby at eecs.northwestern.edu> wrote:
> I think you call the first one on the value and the second on each of
> the components of the value where you want to recur.

Ok, then I really don't understand the library.  The following appears
to be effective:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(require mzlib/pconvert)
(current-build-share-hook
 (let ([original-current-build-share-hook (current-build-share-hook)])
   (lambda (v basic-share sub-share)
     (cond
       [(hash? v)
        (hash-for-each v (lambda (k v)
                           (basic-share k)
                           (basic-share v)))
        (basic-share v)]
       [else
        (original-current-build-share-hook v basic-share sub-share)]))))

(print-convert (hash (shared ([a (cons 1 a)]) a) 1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



According to your message, I should be using sub-share for the
internal pieces.  But when I this do this, I see that it exhausts
memory:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang racket
(require mzlib/pconvert)
(current-build-share-hook
 (let ([original-current-build-share-hook (current-build-share-hook)])
   (lambda (v basic-share sub-share)
     (cond
       [(hash? v)
        (hash-for-each v (lambda (k v)
                           (sub-share k)
                           (sub-share v)))
        (basic-share v)]
       [else
        (original-current-build-share-hook v basic-share sub-share)]))))

(print-convert (hash (shared ([a (cons 1 a)]) a) 1))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Posted on the dev mailing list.