Skip to content

blockexpr "return" keyword selection #3

Open

Description

@JanSharp

For info about blockexpr see this issue.

We need a new keyword as a stand in for return for blockexprs (when compared to immediately invoked function expressions (iife))

My ideas so far are

  • leave
  • exit

but I don't like those. If I had to choose between those two I'd go with leave though.

Keep in mind that this keyword will be followed by an (optional) expression list (exactly like return)

Activity

  1. curiosity-a commented on Nov 24, 2021

    @curiosity-a

    First of all, let's get this out of the way: result should not be a keyword. It is traditionally used as an identifier and should remain that way.

    Personally, I don't like leave, it doesn't have the connotation of returning a value. And exit has the connotation of ending the entire program.

    Now for my suggestions:

    • submit
    • produce
    • serve

    I don't have a clear preference among these three (although I'm not so sure about submit). I selected these words because they have the connotation of returning a value, at least in my opinion.

  2. JanSharp commented on Nov 24, 2021

    @JanSharp
    OwnerAuthor

    Yea no, result will definitely not be it.

    Agreed on leave and exit, that's why I also don't like them.

    submit is a bit similar to result imo where in normal code it already has common meaning, mostly as a submit button. It's better than leave for sure, but still problematic.
    Unfortunately serve is problematic due to politics (or whichever the right term for it is). "recently" git moved the default branch name from "master" to "main" (decided by the community) due to the "master" "slave" terminology. "serve" can very easily be put in the same boat, so I'd rather stay away from that.

    I like produce. I see very few issues with that.

    With all that said, thanks a lot for the input, and my current candidates are

    • break - simple and sweet
    • produce - describes the concept of resulting in values
    • retreat - incredibly similar to return but still different

    There are downsides and upsides to all of those, so I'm still not sure. Definitely better than my initial thoughts though

  3. curiosity-a commented on Nov 24, 2021

    @curiosity-a

    break depends a lot on if you are going to introduce the classical break functionality and how. It may clash with that. And there is always the connotation of that functionality.

    retreat I saw on Discord, but didn't like it. Did't sound fitting. I think it's because it implies moving away, not from one thing to another. Speaking of which, new series of candidates:

    • transfer
    • pass
    • convey
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions