Skip to content
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

[Feature] Explicitly mark failable functions in their signatures #272

Open
mks-h opened this issue Jul 4, 2024 · 1 comment · May be fixed by #300
Open

[Feature] Explicitly mark failable functions in their signatures #272

mks-h opened this issue Jul 4, 2024 · 1 comment · May be fixed by #300
Labels
enhancement New feature or request

Comments

@mks-h
Copy link

mks-h commented Jul 4, 2024

Right now to understand whether a function is failable or not, you have to read through its body to find uses of ? or fail. That, or run the compiler and see if it fails with an error message pointing out to a failable function.

Considering that the way a function is called depends on if it is failable, I believe it is a good idea to make it easier to tell them apart — by putting some indication into the function signature.

To be more specific, I propose to make the error a part of the return type signature, using ? at the end of the type:

fun failing(name: Text): Null? {
    $command$?
    parse(name)?
    fail 1
}

// Not sure if this is necessary, if the function doesn't have types anyway
fun failing(name): ? {
    $command$?
    parse(name)?
    fail 1
}

Although, there may be a better way to do this.

@Mte90 Mte90 added the enhancement New feature or request label Jul 4, 2024
@Ph0enixKM
Copy link
Collaborator

This is a good idea. This will be a breaking change and should be implemented as soon as possible.

@Ph0enixKM Ph0enixKM added this to the Amber 0.4.0-alpha milestone Jul 4, 2024
@Ph0enixKM Ph0enixKM changed the title [Feature Request] Explicitly mark failable functions in their signatures [Feature] Explicitly mark failable functions in their signatures Jul 7, 2024
@mks-h mks-h linked a pull request Jul 12, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants