transparency of structs?

50 views
Skip to first unread message

jos....@gmail.com

unread,
Sep 6, 2019, 3:44:16 PM9/6/19
to Racket Users

Hi

 

Has something changed with transparency of structs?

I find the following:

 

#lang racket/base

 

(module a racket/base

(define inspector (make-inspector))

(define-values (descr constr pred acc mut)

  (make-struct-type 's #f 2 0 #f '() inspector #f '(0)))

(define an-s (constr 'monkey 'lion))

(provide an-s))

 

(module b racket/base

(define inspector (make-inspector))

(struct s (f g) #:inspector inspector)

(define another-s (s 'monkey 'lion))

(provide another-s))

 

(require 'a 'b)

 

(define (print-info s)

(printf "s = ~s~n" s)

(printf "struct? ~s~n" (struct? s))

(define-values (descr skipped?) (struct-info s))

(define-values (name n m ref set immut super skip) (struct-type-info descr))

(printf "ref : ~s~n" (ref s 0)))

 

(print-info an-s)

(print-info another-s)

 

Produces:

                                          

s = #(struct:s monkey lion)

struct? #t

ref : monkey

s = #(struct:s monkey lion)

struct? #t

ref : monkey

 

I expected for example (struct? an-s) to yield #f.

What am I confusing?

Thanks, Jos


This email has been scanned by BullGuard antivirus protection.
For more info visit www.bullguard.com

Ben Greenman

unread,
Sep 7, 2019, 7:20:11 PM9/7/19
to jos....@gmail.com, Racket Users
I see the same results on Racket 7.0 and 6.5, so I don't think
anything has changed.

Maybe the trouble is that (make-inspector) makes a subinspector of
(current-inspector), which has the same value for both the main module
& the submodules.

Switching to (make-sibling-inspector) causes (struct? an-s) to return #f

jos....@gmail.com

unread,
Sep 8, 2019, 8:36:09 AM9/8/19
to Ben Greenman, Racket Users, jos....@gmail.com
Thanks,
make-sibling-inspector does what I want.
Jos

-----Mensaje original-----
De: Ben Greenman <benjamin...@gmail.com>
Enviado el: 08 September 2019 01:20
Para: jos....@gmail.com
CC: Racket Users <racket...@googlegroups.com>
Asunto: Re: [racket-users] transparency of structs?

I see the same results on Racket 7.0 and 6.5, so I don't think anything has changed.

Maybe the trouble is that (make-inspector) makes a subinspector of (current-inspector), which has the same value for both the main module & the submodules.

Switching to (make-sibling-inspector) causes (struct? an-s) to return #f


Reply all
Reply to author
Forward
0 new messages