[Prev][Next][Index][Thread]

Re: function signature type checking



In article <usnayu589.fsf@telus.net>, Ray Blaak <blaak@telus.net> 
wrote:

> "Scott McKay" <swm@mediaone.net> writes:
> > "Ray Blaak" <blaak@telus.net> wrote in message
> > > This is the kind of thing I would like to be able to do:
> > >
> > >   define signature <accumulator> (sum :: <number>; n :: <number>)
> > >     => result :: <number>;
> > 
> > You don't need anything magic here.  This signature is "just"
> > 
> >   limited(<function>,
> >              required-parameters: #[<number>, <number>],
> >              result-type: #[<number>])
> > 
> > Unfortunately, what I just wrote is not enough to do the job, because
> > there are a bunch of other things to worry about.
> 
> What I was explicitly trying to do was to split the notion of a
> callable function from a signature specification into separate types.

The result of "limited()" isn't a function.  It's a type.  Like "array 
of integers".


> My reason for thinking about this approach is because that is how some 
> other languages have dealt with the issue: Ada's and Pascal's function 
> pointers, Java's interfaces, etc. In these cases there is a notion of a 
> "specification" type (i.e. signature) that is a separate beast from
> actual functions, but the compiler and runtime can check that they
> conform.

That's exactly what the results of the limited() function are.  Types 
(or "specifications") for objects, not the object itself.

-- Bruce



Follow-Ups: References: