4 ms·
This reminds me a lot of `goto`...
by armchairhacker 3y ago
This reminds me a lot of `goto`...
- FeepingCreature 3y ago(Author) I mean, any nonlocal control flow is a form of goto. Break, continue directly; but loops as well. I put breakelse in the structured-flow category, because like break and continue, you can't use it to enter scopes, only exit them.
- quickthrower2 3y agoProbably not as you cant go to an arbitrary location especially a different call stack
- noobermin 3y agobut why not just use goto actually? You also cannot, at least in C++, not jump to an arbitrary location, it must be within the current function.
- Snild 3y agoOne could ask the same thing about `for` and `while`: why not just use `if`s and `goto`s? Because they're convenient and useful constructs. I don't know if `breakelse` is too, but maybe -- especially when part of a `?` operation.
- quickthrower2 3y agosometimes less flexibility is good.
- unnouinceput 3y agoIt is good old "goto" from Basic, but is a specially lobotomized "goto" instead of having the full power of a normal "goto". And the article's author goes like "With a bit of syntax sugar, this gives a novel alternative to conditional-access operators.". Novel? For what year? 1970? Definitely not for 2023
- avgcorrection 3y ago> Novel? For what year? 1970? Definitely not for 2023 Yeah I sometimes see this sentiment that you don't really need something roughly like sum types and higher-order functions to do things like chaining on them; you just need this one little special-cased keyword that will do 95% of what you want.
- FeepingCreature 3y agoI realize this is a bit passe, but there were reasonable arguments brought back then about goto and its harmfulness, that I personally find very convincing. :P Do you have precedent for something like breakelse as an explicit operation?
- hirako2000 3y agoCalling it lobotomized goto is not misplaced but associating an unethical "medical practice" is very deragagory and totally unjustified towards breakelse. The novelty is not making goto worse, it makes it better. Let me rephrase your statement and see whether the claim that this isn't worth calling it novel stoll stands: > It is good old "goto" once found in many early programming languages, which overtime prove too dangerous even in the hands of great coders hence faded away. The author proposes a safe, goto in disguise, mechanism that can be used as optimisation. May I ask how many novelty aren't either a simple iteration over some existing idea, bringing together some existing ideas, or removing some undesired side effect of an idea
- teo_zero 3y agoBut goto is a statement. What TFA advocates for is 1) an expression that can be used whenever expressions are expected, in particular inside a .case(), and then 2) a bit of syntactic sugar to abbreviate the verbose phrase .case(:else:breakelse) into a convenient one-character symbol.