Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Feature] Convert Bool functions to Failable counterparts

Open Ph0enixKM opened this issue 1 year ago • 1 comments

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 avatar Jan 04 '25 22:01 Ph0enixKM

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

lens0021 avatar Jan 04 '25 22:01 lens0021