Add Ability for Explicit Returns: Add The "Return" Keyword #2695
Mac-Mann
started this conversation in
Ideas & suggestions
Replies: 1 comment 2 replies
-
Hello! Gleam is an entirely expression based language, so there's no early returns or other indirect flow control. This makes a For a return keyword to be useful we would need to permit early returns, but this would become extremely confusing alongside Gleam's pub fn go() {
let items = [1, 2, 3]
use <- list.each(items)
return "Returning early"
} This looks it returns |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello 👋🏻
As the title suggests, I think having this as an optional keyword in Gleam to explicitly return in Gleam would help add clarity. In additional, providing the ability to explicitly execute and end a functional invocation in a given block provides more options when designing code.
Finally, given the recent uptick in YT videos and folks becoming aware of Gleam, one thing I have noticed is that not having an option for explicit returns is the biggest turn-off to adopting Gleam held by many.
Curious what people think about this idea? I personally don't see much harm in adding this functionality, and it wouldn't break anything in terms of old Gleam code.
Beta Was this translation helpful? Give feedback.
All reactions