[racket-dev] for loops with interleaved escape continuations
On Wed, Jul 2, 2014 at 12:52 AM, John Clements
<clements at brinckerhoff.org> wrote:
>
> On Jul 1, 2014, at 3:46 PM, Sam Tobin-Hochstadt <samth at cs.indiana.edu> wrote:
>
>> I disagree strongly that this is un-rackety. Consider the following loop:
>>
>> (define v ....)
>> (let loop ([i 100])
>> (define e (vector-ref v i))
>> (cond [(zero? i) null]
>> [(= 999 e) null]
>> [(even? e) (loop (add1 i))]
>> [else (cons e (loop add1 i))]))
>>
>> I don't think that's un-Rackety.
>>
>> Here's that loop with break/continue:
>>
>> (for/list ([i (in-range 100 0 -1)])
>> (define e (vector-ref v i))
>> (cond [(= 999 e) (break)]
>> [(even? e) (continue)]
>> [else e]))
>
> You don’t like the non-capturing alternative
>
> (for/list ([i (in-range 100 0 -1)]
> #:continue continue
> #:break break)
> (define e (vector-ref v i))
> (cond [(= 999 e) (break)]
> [(even? e) (continue)]
> [else e]))
>
> ?
Sorry, I meant to write the hygenic version that you provide.
Sam
>
> Sorry, I’m working on implementing hygiene for Rust right now, and I’m kind of knee-jerk in favor of non-capturing….
>
> John
>
>>
>> I don't think that's un-Rackety either.
>>
>> Sam
>>
>> On Tue, Jul 1, 2014 at 10:59 PM, Neil Van Dyke <neil at neilvandyke.org> wrote:
>>> If adding break&continue features to your fancy iteration syntax, I propose
>>> that any uses of these features in source code be somehow very prominent.
>>>
>>> For example, perhaps there is a keyword that must be at the top of the fancy
>>> iteration form, something like
>>> "#:enable-continue-here-because-programmer-cannot-be-bothered-to-write-this-in-idiomatic-racket".
>>>
>>> This prominence warns readers of the code to be on the lookout for surprise
>>> control flow (like they would on the rare occasion that they saw a "call/ec"
>>> around a loop). It also hints to newbie programmers that they are
>>> discouraged from simply transliterating syntax from other languages (rather
>>> than learning better control flow and structuring techniques).
>>>
>>> Neil V.
>>>
>>>
>>> _________________________
>>> Racket Developers list:
>>> http://lists.racket-lang.org/dev
>>>
>> _________________________
>> Racket Developers list:
>> http://lists.racket-lang.org/dev
>