| 18:13 | <bakkot> | writing up the spec for base64 and I really want to use break/continue |
| 18:13 | <bakkot> | what if we defined those |
| 18:13 | <bakkot> | the alternative is "repeat, while done is false" and then a great deal of nesting |
| 18:18 | <Michael Ficarra> | we have early returns, so you could technically use that |
| 18:21 | <Michael Ficarra> | also, that reminds me that I wanted to clarify that early returns do, in fact, skip steps that follow |
| 18:51 | <ljharb> | a separate AO with early returns seems nice |
| 18:51 | <ljharb> | also, that reminds me that I wanted to clarify that early returns do, in fact, skip steps that follow |
| 18:55 | <Michael Ficarra> | in some (older) programming languages, you could just set a return value at any point in the function (or multiple points) and continue execution |
| 18:56 | <Michael Ficarra> | there's no reason to believe that someone reading the spec steps should assume "return" also means "and stop executing further steps" |
| 18:56 | <Michael Ficarra> | it could reasonably be understood to mean "set the return value to this" |
| 18:56 | <shu> | i think you're confusing setting the return value with a statement saying, control is returned |
| 18:57 | <shu> | the older PLs separated the two, but i don't know of any PL that has something that says "return" but doesn't return control |
| 18:58 | <bakkot> | restructuring flow to use early returns instead of break/continue can make it worse |
| 18:58 | <bakkot> | in this case there is a fair bit of state which would need to be passed into the continuation AO |
| 18:59 | <bakkot> | also that doesn't work for continue unless we replace the whole loop with recursion, which would also be worse |
| 19:04 | <Michael Ficarra> | the older PLs separated the two, but i don't know of any PL that has something that says "return" but doesn't return control |
| 19:05 | <Michael Ficarra> | restructuring flow to use early returns instead of break/continue can make it worse |
| 19:05 | <bakkot> | so, agreed we should add break/continue? |
| 19:05 | <Michael Ficarra> | no |
| 19:06 | <bakkot> | aww |
| 19:06 | <Michael Ficarra> | what do you think about "go to step <emu-xref ..." |
| 19:06 | <bakkot> | at least a couple other proposal authors have asked for it |
| 19:06 | <bakkot> | uhhhhhhhh |
| 19:06 | <Michael Ficarra> | you like it, don't you? |
| 19:06 | <bakkot> | not sure goto is better than break/continue but I guess if we carefully don't abuse it it would be ok? |
| 19:07 | <Michael Ficarra> | I think I prefer it |
| 19:08 | <bakkot> | I think that most proposal authors / readers would be more comfortable with break/continue than goto |
| 19:08 | <bakkot> | so can you say more about why you would prefer it? |
| 19:09 | <Michael Ficarra> | it's dead simple for a reader |
| 19:10 | <bakkot> | so is break/continue, as long as the reader is at all technical |
| 19:10 | <Michael Ficarra> | no chance to like incorrectly match it up with the containing repetition or go to the wrong instruction |
| 19:11 | <Michael Ficarra> | also, "go to step X" is familiar for any reader |
| 19:12 | <bakkot> | yeah but many possible uses are incoherent so when you read it you need to convince yourself it's coherent |
| 19:12 | <bakkot> | and the only uses I would want to allow are break/continue |
| 19:12 | <bakkot> | so for technical readers, you'd have to manually translate it to break/continue |
| 19:12 | <bakkot> | which is dumb |
| 19:12 | <bakkot> | we should just write the thing we mean |
| 19:24 | <bakkot> | anyway I would be ok with goto instead, it just seems dumb |
| 19:24 | <bakkot> | would like to hear from shu I guess |
| 19:30 | <ljharb> | with the AO and state passing, would a Record cover that? |
| 19:36 | <bakkot> | you still have to construct and pass said record, and record fields are more annoying than local variables, so no, not really |
| 19:54 | <shu> | brothers i love goto |
| 19:55 | <shu> | jump jump jump jump jump |
| 19:55 | <shu> | jump around |
| 19:58 | <jmdyck> | @bakkot: would you allow 'break' in For, Repeat, and While ? |
| 20:08 | <bakkot> | jmdyck: yes |
| 20:08 | <bakkot> | assuming by "while" you mean "Repeat, while" |
| 20:10 | <jmdyck> | Actually, there's one step that starts "While", in CleanupFinalizationRegistry. But it doesn't want a break now, and probably won't in future, so probably no loss to leave it out. |
| 20:12 | <bakkot> | yeah that's not exactly a loop anyway |
| 20:13 | <jmdyck> | With Repeat, there's Repeat-while, Repeat-until, and Repeat-forever |
| 20:16 | <jmdyck> | (Repeat-forever currently exits via explicit or implicit 'Return') |
| 20:43 | <Richard Gibson> | break/continue, but only labeled
|
| 20:52 | <bakkot> | sgtm |
| 20:56 | <ljharb> | semantics sound good, but "break out of" would need a pretty clear definition |
| 21:06 | <Michael Ficarra> | nah, I still prefer goto |
| 22:00 | <jmdyck> | So then it would get rendered as (e.g.) "ii. If i ≥ len, break out of 2.c." |
| 22:02 | <jmdyck> | and "iv. If next is undefined, continue to 2.c." |
| 22:07 | <jmdyck> | Might want to insert "step". |
| 22:11 | <jmdyck> | To simulate a 'break' with 'go to', you'd need to go to the step after the loop, so you'd have to label that step, but then someone might insert a step before that, without realizing that the label needs to be moved. (Similarly if the labelled step needs to move elsewhere.) |
| 22:16 | <jmdyck> | To simulate a 'continue' with 'go to', I suppose you'd put a do-nothing step at the end of the body and go to that. |
| 22:34 | <Michael Ficarra> | jmdyck: for continue, you can just point to the loop head |
| 22:54 | <jmdyck> | That wouldn't be very clear: could suggest restarting the loop. |
| 22:57 | <Michael Ficarra> | what does restarting mean? |
| 22:57 | <Michael Ficarra> | I don't see how it could possibly be misinterpreted |
| 22:58 | <jmdyck> | restarting means execute the step, same as if you go to it from outside. |
| 22:59 | <Michael Ficarra> | ... that is the correct behaviour? |
| 23:02 | <Michael Ficarra> | oh I see, you're thinking of using it with "For ..." loops |
| 23:02 | <Michael Ficarra> | I was only considering "repeat" |
| 23:03 | <jmdyck> | right. |
| 23:03 | <Michael Ficarra> | let's not do that |
| 23:04 | <jmdyck> | hah |
| 23:05 | <shu> | have i said i love goto |
| 23:11 | <jmdyck> | yes, but your intonation is kind of faint |