[plt-scheme] detecting parameter types (contracts?)

From: Corey Sweeney (corey.sweeney at gmail.com)
Date: Thu Aug 30 11:10:48 EDT 2007

Oh, I understand the puzzle.  Your "input type/contract" can be
arbitrairly complicated, like:

(define valid-input? (lambda (x) (and (number? x)
                                                    (not (= 7 x)))))

I was just hoping that the primative functions may have been simple
enough to have something that worked.  But no worries.  I've written
my own "type table" for my purposes.

Corey

On 8/30/07, Robby Findler <robby at cs.uchicago.edu> wrote:
> procedure? but I think you're missing the point of the puzzle.
>
> Robby
>
> On 8/30/07, Corey Sweeney <corey.sweeney at gmail.com> wrote:
> > On 8/30/07, Noel Welsh <noelwelsh at gmail.com> wrote:
> > > Certainly not in general.  Consider this:
> > >
> > > What is the type of the first argument to map?
> >
> > That would look like type "function"
> >
> > hmm, i could swear that there was something like this:
> > > (function? (lambda (x) x))
> > . reference to undefined identifier: function?
> > > (proc? (lambda (x) x))
> > . reference to undefined identifier: proc?
> >
> > maybe i'm thinking of a guile-ism
> >
> > However, I do see the issue that some procedure could accept either a
> > number OR a string, which would not be a simple answer.
> >
> > Corey
> >
> >
> > Corey
> >
> >
> > >
> > > N.
> > >
> > > On 8/30/07, Corey Sweeney <corey.sweeney at gmail.com> wrote:
> > > > Is there a way to automatically detect paramater types of the
> > > > primative functions?  I'm guessing not, but perhaps the "contracts"
> > > > functions have something in them.  While this example is highly
> > > > contrived, I'll present a example to be clear on what i'm looking for:
> > > >
> > > > (+ (if (equal? 'number (get-type-of-parameter-1 +))
> > > >        2
> > > >        "nifty string")
> > > >    7)
> > > >
> > > > or in english:
> > > > Given the function +, is there a way to automatically determine wether
> > > > i should be passing it a number, a symbol, or a string?
> > > >
> > > >
> > > > Corey
> > >
> >
> >
> > --
> > ((lambda (y) (y y)) (lambda (y) (y y)))
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >
>


-- 
((lambda (y) (y y)) (lambda (y) (y y)))


Posted on the users mailing list.