-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for failable mark to function declarations #300
base: master
Are you sure you want to change the base?
Conversation
Failable functions which specify return type must be marked with a question mark after the type, with a space in-between. Example: fun failable(): Null ? { fail 1 } Non-failable functions must not be marked as failable.
Allow marking non-failable functions as failable.
Right now there are two versions:
Which route should be taken here? If we allow declaring non-failable functions to be failable, then should a warning be emmited? If so, should there be a compiler flag to remove it? |
Allowing to mark non-failable functions can be seen as a feature to allow API stability. However, this obviously allows for misuse — having too many pseudo-failable functions in libraries would make it more annoying to use them. Maybe for now it is a good idea to stick to the more strict but minimal rule of "only failable functions must be marked". Then, it would be possible to relax it, if ever needed. |
The difference with unsafe is...? In this way when we will improve docs we can explain it. |
...that they are completely different things
it will help for user to know if the function is failable or not, and probably open up a possibility for handling a runtime error in the function (like |
To clarify, this change does not add any new features. It only creates a requirement to mark failable functions with the Well, the last commit does add a new feature of marking any function with the |
@mks-h so it kinda just ignores the |
In the first case, it throws an error if there's a P.S. Technically it changes the "failable" property to true, instead of just ignoring the mark. |
ah, so it would just pass an error along if there is a |
Makes it a requirement to declare failable functions as such, using
?
failable mark.Syntax:
Resolves #272