[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [Proposal] break do end
- From: Coda Highland <chighland@...>
- Date: Wed, 27 Aug 2014 20:03:42 -0700
On Wed, Aug 27, 2014 at 8:02 PM, Rena <hyperhacker@gmail.com> wrote:
> On Wed, Aug 27, 2014 at 11:00 PM, Coda Highland <chighland@gmail.com> wrote:
>> On Wed, Aug 27, 2014 at 7:35 PM, Thiago L. <fakedme@gmail.com> wrote:
>>>
>>> On 27/08/14 11:34 PM, Coda Highland wrote:
>>>>
>>>> On Wed, Aug 27, 2014 at 7:17 PM, Thiago L. <fakedme@gmail.com> wrote:
>>>>>
>>>>> It would be cool if you could use break with do ... end for some sort of
>>>>> "safe goto"
>>>>>
>>>>> Example:
>>>>>
>>>>> do
>>>>> break
>>>>> local x = "you'll never see me"
>>>>> print(x)
>>>>> end
>>>>> print("something")
>>>>>
>>>>> Would print "something"
>>>>>
>>>>> In 5.2+ we have this:
>>>>>
>>>>> goto x
>>>>> local x = ""
>>>>> ::x::
>>>>> print("something")
>>>>>
>>>>> But it errors instead of doing the scoping stuff you can do with do ...
>>>>> end
>>>>>
>>>>> (This is probably not something for lua 5 but for lua 6 if/when we get
>>>>> it...
>>>>> it would probably be less harmful to change goto so that it does an
>>>>> implicit
>>>>> do ... end scoping thingy)
>>>>>
>>>> repeat
>>>> -- statements here
>>>> break
>>>> -- rest of statements skipped
>>>> until false
>>>>
>>>> /s/ Adam
>>>>
>>> until true*, but that's uglier
>>>
>>
>> No, until true would make it loop. until false makes the body of the
>> loop execute exactly once.
>>
>> /s/ Adam
>>
>
> The logic is "until true == true", so it will only loop once. You're
> thinking of "while true".
>
> --
> Sent from my Game Boy.
>
Er. Right. Yes, I'm thinking of while. Sorry, I'm derping today. ^^()
/s/ Adam