[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Numeric for loop with rationals
- From: Dirk Laurie <dirk.laurie@...>
- Date: Tue, 30 Jan 2018 15:04:18 +0200
2018-01-30 14:55 GMT+02:00 Soni "They/Them" L. <fakedme@gmail.com>:
>
>
> On 2018-01-30 10:51 AM, Dirk Laurie wrote:
>>
>> 2018-01-30 14:23 GMT+02:00 Soni "They/Them" L. <fakedme@gmail.com>:
>>>
>>>
>>> On 2018-01-30 06:58 AM, Francisco Olarte wrote:
>>>>
>>>> On Tue, Jan 30, 2018 at 1:11 AM, Soni "They/Them" L. <fakedme@gmail.com>
>>>> wrote:
>>>> ...
>>>>>
>>>>> Also, rationals are still numbers. They're just not "Lua numbers"
>>>>> (objects
>>>>> with type(x) == "number"). Any language with operator overloading (e.g.
>>>>> C++)
>>>>> lets me have numeric for with rationals. Except Lua. (Python doesn't
>>>>> have
>>>>> numeric for at all so it doesn't count.)
>>>>
>>>> C++ does not have numeric for, so it doesn't count either.
>>>>
>>>> Francisco Olarte.
>>>>
>>> for (int i = 0; i < 100; i++) { printf("%d\n", i); }
>>>
>>> Looks like it does, it's just more flexible than Lua's.
>>
>> No 'for' is more flexible than Lua's.
>>
>> for a,b,c,as_many_as_you_like in myiter(anything) do
>> end
>>
>
> Sorry, C++'s numeric for is more flexible than Lua, because it gives you
> more control over the iteration.
>
> You can also use rational objects which overload < and ++ in C++ numeric
> fors, while you can't in Lua even with __add and __lt.
C/C++ does not have a numeric for, it only has a generic for.
for (statement_list_1;statement_list_2;statement_list_3) do statement;
Nothing numeric about that.
No restriction anywhere, although if statement_list_2 is just an
assignment most compilers will recommend that you put it in
parentheses.