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

function signature type checking



I am just learning Dylan, and have a question about the type checking of
functional parameters and results.

It seems that the right way is to declare the type of the parameter or result
to be <function>.

Is there a way to further specialize this? For example, I might be returning a
predicate, and so I desire compiler support that verifies my functional result
is a <function> that takes a single appropriate argument and returns a
<boolean>. No other functions are correct.

It doesn't seem to me that this is supported. There doesn't seem to be a way
to create functional signature types. <function> and <method> are sealed, and
I am not sure where some sort of <signature> extensible type would fit in
anyway, since conformance to a signature is a structural equivalence thing,
rather than being properly in the type heirarchy.

If I really want typed functional results, the only thing I can think of is to
wrap up by results in some sort of invocation class that has a single method
of the appropriate signature, similar to Java's call-back style with
interfaces. This does complicate usage, however.

Thoughts?

-- 
Cheers,                                        The Rhythm is around me,
                                               The Rhythm has control.
Ray Blaak                                      The Rhythm is inside me,
blaak@telus.net                                The Rhythm has my soul.



Follow-Ups: