8000 vine: overhaul control flow by tjjfvi · Pull Request #314 · VineLang/vine · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vine: overhaul control flow #314

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

Merged
merged 27 commits into from
Jul 7, 2025
Merged

vine: overhaul control flow #314

merged 27 commits into from
Jul 7, 2025

Conversation

tjjfvi
Copy link
Member
@tjjfvi tjjfvi commented Jul 4, 2025

Likely easiest to review commit-by-commit, as there are a lot of changes here.

@tjjfvi tjjfvi requested a review from nilscrm July 4, 2025 23:46
Copy link
Contributor
@nilscrm nilscrm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, lots of good stuff!

Here're my thoughts on the different features:
else for while and for: Very handy, I like it

when: really useful, love it

removal of else if: I don't really like it. Event with the when statement there are still situation where else if is nicer I think (see comments). Does keeping it come at any cost?

let / else match: I like it especially for thinks like errors

no implicit continue in loops: I strongly dislike it. I think the semantics get less intuitive and this is especially bad in loops that are basically while loops but break in the the middle or at the end, e.g. find_primes.vi. One could make the argument that with a mandatory continue at least the compiler would warn you, but I think that would add verbosity. Seeing all the changes there are also already more continues added than breaks removed.

keywords as break target: Quite useful, haven't seen that before but I like it

return, break, continue: As discussed before, solid choice

annotation of return type of control flow structures: Probably very useful in cases where type inference is lost

non-divergence let /else: I'm unsure, for me it's a little too implicit and it sounds somewhat like you're choosing an alternative value for the let assignment.

@tjjfvi
Copy link
Member Author
tjjfvi commented Jul 5, 2025

Regarding else if: in both of the examples you mentioned preferring else if, it seemed like the main complaint was the empty _ {} arm. I think it would make sense to stop requiring this, as it adds no additional information. Would that resolve your concerns?

@nilscrm
Copy link
Contributor
nilscrm commented Jul 5, 2025

Regarding else if: in both of the examples you mentioned preferring else if, it seemed like the main complaint was the empty _ {} arm. I think it would make sense to stop requiring this, as it adds no additional information. Would that resolve your concerns?

Yeah I think it makes sense to not require an empty arm and only have match statements check for exhaustiveness. I think it would also remove most of my concerns, but on the other hand I feel like we're not giving anything up by supporting the very standard else if. One situation I can see it being useful is when you have a few nested conditions where whens would introduce twice the level of indentation.

@tjjfvi
Copy link
Member Author
tjjfvi commented Jul 5, 2025

Yeah I think it makes sense to not require an empty arm and only have match statements check for exhaustiveness.

👍

I feel like we're not giving anything up by supporting the very standard else if.

I don't think it's good to have two different constructs that do the same thing; it creates questions of when which should be used, potentially requires converting between them, and makes code written in the language less consistent.

One situation I can see it being useful is when you have a few nested conditions where whens would introduce twice the level of indentation.

If one has nested conditions to the point that the increased indentation is excessive, a refactor is probably warranted.

@tjjfvi 8000
Copy link
Member Author
tjjfvi commented Jul 6, 2025

I've removed the requirement for the terminal arm in whens. After discussing some more offline, I'd like to move forward with the changes to loop and let/else.

@tjjfvi tjjfvi requested a review from nilscrm July 6, 2025 21:15
@tjjfvi tjjfvi added this pull request to the merge queue Jul 7, 2025
Merged via the queue into main with commit 87a6a2b Jul 7, 2025
6 checks passed
@tjjfvi tjjfvi deleted the control-flow branch July 7, 2025 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants
0