|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Re: PartialFunction and Functionbut PartialFunction extends Function (seems wrong way round, at least according to the mathematical definition of function and partial function). http://lampsvn.epfl.ch/trac/scala/ticket/85 "equate PartialFunction with Function ?" After lengthy discussion, this ticket is suddenly closed as invalid with the transparency classic "After lots of discussion at EPFL, the group has decided to keep things how they are." It comes up a lot. Partials are unnecessarily clumsy to use, and it's a bummer because they're so freaking useful. My thoughts on this: The issue seems to be that really: Function = "Partial function with no explicit information about which values it will terminate on" PartialFunction = "Partial function with explicit information about which values it will terminate on" So collapsing the two (PartialFunction and Function) into one class does make a lot of sense to me. But perhaps the reason this wasn't done before is that this solution would leave you unable to distinguish between, eg: * isDefinedAt defined true everywhere as a kind of default fallback when no information was explicitly given about where the function terminates * isDefinedAt intentionally defined true everywhere to communicate that the function was defined to terminate everywhere So, my suggestion is to have an interface on Function which allows you to determine 2 things: * Is explicit information available on whether the function terminates? * If so, what is that information? That interface could be like, eg: def definedInformationAt(a : A) : Option[Boolean] returning Some(true) where the function is known/guaranteed to terminate on that value Some(false) where the function is known/guaranteed not to terminate on that value None where there's no explicit information about whether it terminates on that value. Think that would help at all? worth suggesting on the ticket? -Matt |
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |