Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
2015 009 Policy for exceptions and partial applications
Policy for exceptions and partial applications
Some curried functions in the Basis Library will raise an exception when their first argument is invalid.
The Basis Library specification is not consistent in specifying if the exception should be raised at the
time of the partial application to the invalid argument or at the time of the application to the last
In the case of
Real.fmt), the specification
states that the exception should be raised on the partial application to the invalid argument. In the
Time.fmt, the behavior in unspecified.
The purpose of this proposal is to define a uniform behavior for this situation, both for the existing Basis Library and for future proposals. Specifically,
if a curried function raises an exception because of an invalid input, then it should raise that exception as soon as it is partially applied to the invalid input.
Adopting this policy means that the following change should be made to the description of
Replace the sentence
n< 0 causes the
Sizeexception to be raised.
n< 0 causes the
Sizeexception to be raised when
fmt nis evaluated.
Some versions of SML raise the exception at the point where the last argument is supplied (e.g., SML/NJ prior to 110.79). These implementations will have to be modified to implement the correct behavior. It is possible, but not likely, that there might be code that depends on the behavior of these implementations, but such code would not work on other implementations, so it ought to be fixed anyway.
There is also a potential implementation cost for adopting this behavior, since it prevents the application of the uncurrying transformation to an application of one of these functions to all of its arguments.
Providing a uniform policy for curried functions will provide predictable behavior of these functions and provide a guide for the semantics of future proposals involving curried functions.
- [2015-08-22] Proposed