Liste des Groupes | Revenir à cl c |
On 2025-04-16, bart <bc@freeuk.com> wrote:OK, I've had a look in detail at the code I generate for for-loops.On 16/04/2025 22:43, Kaz Kylheku wrote:Sure, but you could have a loop that goes over the last nOn 2025-04-16, bart <bc@freeuk.com> wrote:>On 16/04/2025 06:35, Janis Papanagnou wrote:>On 15.04.2025 22:46, bart wrote:>On 15/04/2025 20:07, Scott Lurndal wrote:[...]>
Real for loops _are_ a three-way construct.
>
[...]
Any step other than 1 is unusual. [...]Nonsense. Arithmetic loop steps other than one are noting unusual>
and been supported by programming languages (and also been used)
since decades in programming.
So what are you claiming, that the majority of loops in any given
program will have steps other than +1 or -1?
Hey Bart, how would you handle a loop like
>
do x = m to n ...
>
where m and n are not known until run time, and may be the
extreme values of the type? Like C's INT_MIN and INT_MAX, respectively,
where x is of type int.
>
Because in this loop, x takes on every possible value of the type,
we cannot have a loop guard which prevents entry of the loop body
based on solely the value of x.
I'm not exactly sure what you are asking. Is it a loop like this, here
in my language:
>
int n:=0
>
for i in i32.bounds do # ie. i32.min .. i32.max
++n
od
>
println n
>
This works fine; after a second or so it displays 4294967296.
>
However, this languages evaluates using 64 bits. Perhaps this loop may
demonstrate the issues better:
>
for i in i64.bounds do
>
However, I would estimate it would take 190 years to finish.
values of the range of i64, for a reasonably small n.
I assume you're thinking of C which uses i32 and where comparisons nearComparisons aren't; gratuitous increments or displacements are.
the extreme values of the type are problemetical. Or this line in my
Les messages affichés proviennent d'usenet.