[Prev][Next][Index][Thread]
function signature type checking
-
To: info-dylan@ai.mit.edu
-
Subject: function signature type checking
-
From: Ray Blaak <blaak@telus.net>
-
Date: Mon, 26 Nov 2001 12:45:01 -0500 (EST)
-
Organization: The Transcend
-
Sender: blaak@TORUS
-
Xref: traf.lcs.mit.edu comp.lang.dylan:13789
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: