[plt-scheme] define/contract/provide ?

From: Greg Hendershott (greghendershott at gmail.com)
Date: Sat Mar 20 18:35:00 EDT 2010

Wrapping my brain around modules and contracts. Coming from C/C++/C# mindset.

Have successfully used define and provide/contract in a module

Just noticed define/contract. I'm thinking, hey, this is how my C-ish
brain works. Define the function and its types/contract in one swell
foop.

Small annoyance is now I have to type provide by itself.

So I'm wondering, why isn't there a define/contract/provide?  Isn't
doing all three a common scenario when making a module?  Or am I
carrying baggage from my C background?


On a related note, I risked further brain burn by attempting to
provide (sorry) this myself with define-syntax.

Attempt 1 was this:

  (define-syntax-rule (define/contract/provide (id args ...) (contract
...) body-expr ...)
    (begin
      (define/contract (id args ...) (contract ...) body-expr ...)
      (provide id)))

But doesn't work because provide doesn't work inside (begin). No error
making the module, but user of it doesn't see the function since
provide inside begin (I think?).

Attempt 2 was this:

  (define-syntax-rule (define/contract/provide (id args ...) (contract
...) body-expr ...)
    (define/contract (id args ...) (contract ...) body-expr ...)
    (provide id))

But that complains:
  define-syntax-rule: too many templates in: ((provide id))


Thanks in advance for any help!

Greg


Posted on the users mailing list.