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

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

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)))


Posted on the users mailing list.