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] Convert Bool functions to Failable counterparts #658

Open
Ph0enixKM opened this issue Jan 4, 2025 · 1 comment
Open

[Feature] Convert Bool functions to Failable counterparts #658

Ph0enixKM opened this issue Jan 4, 2025 · 1 comment
Labels
enhancement New feature or request pr/breaking This PR introduces a breaking change stdlib

Comments

@Ph0enixKM
Copy link
Member

Is your feature request related to a problem? Please describe.
The use of Bool should always indicate existence of certain attribute. A case for that would be checking if something is switched on or off. Another example would be to get information if certain value exists somewhere. In case of returning a success status, we should always return failure which gives more information about the error (different errors may have different exit codes). This is something that we're not consistent with in the Amber's standard library.

// Example of using boolean to return a status
let success = foo()
if !success {
    echo "Something went wrong :("
}

// Example of failing a function to return a status
let success = foo() failed {
    echo "Failed with exit code: {status}"
}

Describe the solution you'd like
Convert all functions that return Bool value as a status to a failable function equivalent.

Describe alternatives you've considered
N / A

Additional context
Standard Library

@Ph0enixKM Ph0enixKM added enhancement New feature or request pr/breaking This PR introduces a breaking change stdlib labels Jan 4, 2025
@github-project-automation github-project-automation bot moved this to 🆕 New in Amber Project Jan 4, 2025
@lens0021
Copy link
Contributor

lens0021 commented Jan 4, 2025

I agree. The strategy returning false looks like the old PHP code. Nowadays even PHP doesn't do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pr/breaking This PR introduces a breaking change stdlib
Projects
None yet
Development

No branches or pull requests

2 participants