chicken-hackers
[Top][All Lists]
Advanced

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

[Chicken-hackers] wishlist entry: distinguished values for boolean const


From: Jörg F . Wittenberger
Subject: [Chicken-hackers] wishlist entry: distinguished values for boolean constants in type declarations
Date: 20 Mar 2013 21:50:31 +0100

Let's explain the idea by example.

There are many standard (or srfi) procedures, which take either
a distinguished type or (often) a boolean value (typically #f).

For instance mutex-lock: the 1st optional argument is either
a timeout or #f the second is either a thread or #f.

Written as type declaration this looks like this

(: mutex-lock! ((struct mutex) * (or boolean (struct thread)) -> boolean)

Now Chicken will catch (mutex-lock! mymux #f 27); nice.

But it will fail to catch (mutex-lock! mymux 27 #t).

To be consistent with the handling of other distinguished objects like
"()" (expressed as "null") and the eof-of-file-object (likewise "eof")
it would be great, if we had "true" and "false" to restrict these
beyond the rather generic "boolean" in those cases.

Feasible?

Best

/Jörg




............







reply via email to

[Prev in Thread] Current Thread [Next in Thread]