I have a fairly basic question about what checking is done when instances
of structs defined in Typed Racket cross typed–untyped boundaries.

For a concrete example, in the following program, I'm interested in the
call to `container-append` from untyped code:

#lang racket/base

(module typed typed/racket/base
  (provide (struct-out container)
           container-append)
  (define-type SymbolTree
    (U Null Symbol (Pairof SymbolTree SymbolTree)))
  (struct container ([tree : SymbolTree])
    #:transparent)
  (: container-append (-> container container container))
  (define (container-append a b)
    (container (cons (container-tree a)
                     (container-tree b)))))

(require 'typed)

(container-append (container '(a b c))
                  (container '(d e f)))

My hope is that, since `container` is defined in Typed Racket, the contract
generated for `container-append` would only need to check that its
arguments satisfy `container?`: it could rely on the `container`
constructor to assure that the fields have the right types.

I want to know for certain, though, because it seems at least possible that
it might not be sound to assume that `container` instances are valid
(perhaps because of reflective operations or something), in which case the
generated contract would need to traverse the entire data structure. This
would change the complexity of a function like `container-append`.

Assuming the answer to this question isn't likely to change, I think it
would be worth adding to the documentation, perhaps at
http://docs.racket-lang.org/ts-guide/typed-untyped-interaction.html#%28part._.Protecting_.Typed-.Untyped_.Interaction%29
or
http://docs.racket-lang.org/ts-guide/optimization.html#%28part._contract-costs%29.
For the use-case I'm considering, having to traverse the entire data
structure on typed–untyped boundary crossings would clearly be prohibitive.

-Philip

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to