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

Make var/let...else proposal #1758

Open
josh11b opened this issue Jul 27, 2022 · 20 comments
Open

Make var/let...else proposal #1758

josh11b opened this issue Jul 27, 2022 · 20 comments
Labels
long term Issues expected to take over 90 days to resolve.

Comments

@josh11b
Copy link
Contributor

josh11b commented Jul 27, 2022

PR #1388 should be made into a proposal. It just needs the proposal template filled out, with background, rationale, and alternatives. My expectation is that a lot of the rationale can come from looking at how well it has gone in other languages, which likely have already articulated how this feature is good for dealing with the unexpected cases without continually indenting right, for example:

The proposal process is described here: https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/evolution.md .
I in particular recommend the proposals/scripts/new_proposal.py script.

@josh11b josh11b added the good first issue Possibly a good first issue for newcomers label Jul 27, 2022
@rscircus
Copy link
Contributor

@josh11b - can do this. ETA: Sunday.

@PramodhTVK
Copy link

Hey I want to make my first contribution. Can I work on this issue?
Also could I get an explanation as to what exactly are the requirements.

@josh11b
Copy link
Contributor Author

josh11b commented Sep 7, 2022

@PramodhTVK Could you collaborate with @rscircus on #1871 ? I've commented on that PR what we are looking for in this proposal.

@PramodhTVK
Copy link

Sure thing. But pls don't mind me if I pester you too much, since this is my first ever contribution.

@rscircus
Copy link
Contributor

rscircus commented Sep 8, 2022

Hey @PramodhTVK - alright. :) Welcome joining that one. Guess you saw that being tagged as 'good first issue'. So here is my rationale so far and what I am thinking about even though not blarghing everything into here:

Scope

  • This feature is mainly concerned with readability and lowering the mental load on the developer.
    • As far as I see there is not too much research about it, but some. You can find it via scholar. :)
  • As far as I have seen, Swift seems to have popularized that statement with an additional keyword (guard), it calls this a guard statement (or pattern), which I think is a fitting name.
  • It's related to the idea of the Elvis-operator.
  • There is some discussion linked on Discord which should flow into this proposal and also some work by @josh11b which I linked to heavily. And you can find good examples in Rust.

Where are we / am I right now?

Needed a while to understand the motivation and also differentiate between the current fashion and what makes sense. So I am still gathering good data and arguments in shape of reading papers and through other languages. That had a little ramp up as designing computer languages involves touching many different fields. For now I am thinking about a more intuitive alternative and am including all given arguments. It took me a while to grok the concept, so I don't think, it's too obvious to the unenlightened. Actually reading through Swift's guard pattern made it click for me, so the guard keyword -- even though adding a keyword -- made the concept more clear and explained why a = b could have a return value even though it looks like a statement.

@PramodhTVK
Copy link

I will definitely look into it. Is it fine if I take up some time?

@PramodhTVK
Copy link

Where can I find the link to the discord group?

@geoffromer
Copy link
Contributor

Where can I find the link to the discord group?

https://github.com/carbon-language/carbon-lang#join-us

@rscircus
Copy link
Contributor

@PramodhTVK - feel free to continue on this one. I am redirecting my energy to other FLOSS work.

@PramodhTVK
Copy link

Sure Ill look into it.

@josh11b
Copy link
Contributor Author

josh11b commented Nov 3, 2022

FYI, Rust has recently stabilized let...else, see Announcing Rust 1.65.0. On Hacker News, there are some comments saying why they are excited by this features 1, 2.

@josh11b josh11b added the long term Issues expected to take over 90 days to resolve. label Dec 21, 2022
@ashutosh887
Copy link

@josh11b @rscircus @geoffromer I would like to work on this

@rscircus
Copy link
Contributor

Hi @ashutosh887 - good to hear. If you need any help to get started, let me know. :)

@rscircus
Copy link
Contributor

FYI, Rust has recently stabilized let...else, see Announcing Rust 1.65.0. On Hacker News, there are some comments saying why they are excited by this features 1, 2.

On that birthday-comment of mine I replied to a similar comment by @josh11b here: #1871 (comment) where I looked at the other side of the coin.

So overall I am not sure it is such a practical feature actually.

@ashutosh887
Copy link

Thanks @rscircus . Please assign me the issue

@jonmeow jonmeow removed the good first issue Possibly a good first issue for newcomers label Mar 10, 2023
@jonmeow
Copy link
Contributor

jonmeow commented Mar 10, 2023

@ashutosh887 We typically won't assign issues. I've added some documentation for why. Please feel to work on it if you have time, but please through the proposal process to get a better understanding of what to expect.

Also, just to note -- I've checked with josh11b, and considering the proposal process, I've unmarked this as a "good first issue".

@josh11b
Copy link
Contributor Author

josh11b commented Apr 27, 2023

The corresponding feature in Swift is considered a "delight"

@rscircus
Copy link
Contributor

rscircus commented Apr 27, 2023

The corresponding feature in Swift is considered a "delight"

@josh11b - that blog article you are linking to is a blog series of @jrose-apple - Jordan Rose who is blogging about „Regrets“ and „Delights“ of Swift he saw after their developments. One „delight“ was the guard pattern for Optionals as far as I understand this post. There are multiple. Also multiple regrets unfortunately.

Or did you want to point out that it‘s such a delightful feature? 😏

@rscircus
Copy link
Contributor

I am out of this discussion since a while and also changed countries, so forgive my question: Is this feature proposal focusing on an ‘Optional‘ like feature? I remember it being rather general. Considering Optionals it makes sense, but generally?

@geoffromer
Copy link
Contributor

I would recommend aiming for a more general feature, for a few reasons:

  • All else being equal, it's better not to impose limitations unnecessarily.
  • We generally try to avoid privileging particular types at the language level.
  • We don't have a design for Optional yet, which will make it hard to design an Optional-specific version of this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
long term Issues expected to take over 90 days to resolve.
Projects
None yet
Development

No branches or pull requests

6 participants