[racket-dev] Blame and re-provided bindings
FWIW, Casey and I talked about this in my office and I've long advocated that
(require "f.rkt") ;; provide/contract's f with some contract
(provide f)
or
(require "f.rkt") ;; provide/contract's f with some contract
(provide (all-from-out "f.rkt"))
should be the equivalent of:
(require "f.rkt")
(provide/contract [f any/c])
as far as the contract library is concerned, but now I'm starting to
think that that is not convenient enough. Instead, we should really
default to 'provide f with the same contract it had before, as if the
programmer had copied and pasted the contract' (so change the blame
labels) instead of the more high-falutin' interpretation I had before.
So, this means it still will be the case that
(provide f)
is shorthand for
(provide/contract [f any/c])
in some cases, but only when the variable is defined in the given
module, not require'd in.
Robby
On Fri, Jan 14, 2011 at 1:40 PM, Casey Klein
<clklein at eecs.northwestern.edu> wrote:
> The new, nicely formatted blame messages helped me discover that every
> single Redex contract has the wrong negative party. (Admittedly, the
> commonly used Redex provides are macros.) There are two problems.
>
> I believe the first is a bug. The following program (module
> dependencies DAG: http://pastebin.com/u9KMTnuP) blames d.rkt, even
> though the abused function never passes through its hands.
>
> a.rkt:
> #lang racket
> (require "b.rkt")
> (f 3.5)
>
> b.rkt:
> #lang racket
> (require "c.rkt" "d.rkt")
> (provide (all-from-out "c.rkt"))
>
> c.rkt:
> #lang racket
> (require "e.rkt")
> (provide/contract
> [f (-> integer? integer?)])
>
> d.rkt:
> #lang racket
> (require "c.rkt")
>
> e.rkt:
> #lang racket
> (define (f x) x)
> (provide f)
>
> The second problem is that, AFAIK, there's no convenient way to define
> a module b that combines the provides of two modules c and d. If b
> requires c and d and provides values f and g using `all-from-out',
> then b, not the module that requires it, becomes the negative party on
> the f and g contracts.
>
> a.rkt:
> #lang racket
> (require "b.rkt")
> (f 3.5)
>
> b.rkt:
> #lang racket
> (require "c.rkt" "d.rkt")
> (provide (all-from-out "c.rkt" "d.rkt"))
>
> c.rkt:
> #lang racket
> (define (f x) x)
> (provide/contract
> [f (-> integer? integer?)])
>
> d.rkt:
> #lang racket
> (define (g x) x)
> (provide/contract
> [g (-> string? string?)])
> _________________________________________________
> For list-related administrative tasks:
> http://lists.racket-lang.org/listinfo/dev
>