c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Compile time $foreach_r

Open data-man opened this issue 3 weeks ago • 7 comments

For consistency and code simplification.

data-man avatar Nov 28 '25 14:11 data-man

Argument against this: there is neither $while nor $do $while. It's not supposed to be a strict 1:1

lerno avatar Nov 28 '25 15:11 lerno

Argument for this: I have the working patch. :)

data-man avatar Nov 28 '25 15:11 data-man

Argument for this: I have the working patch. :)

Knowing Christoffer, it would be more productive to provide a showcase where $foreach_r would be extremely helpful. Remember, that C3 is trying to be minimalistic and have only nesessary (widely used) functionality.

EroMrinin134 avatar Nov 28 '25 16:11 EroMrinin134

With that argument a lot of things removed from C3 should be in the language.

lerno avatar Nov 28 '25 16:11 lerno

Note that it is not particularly hard to write a macro that takes a compile time list and reverses it for reverse foreach

lerno avatar Nov 30 '25 01:11 lerno

Argument for this: I have the working patch. :)

Knowing Christoffer, it would be more productive to provide a showcase where $foreach_r would be extremely helpful. Remember, that C3 is trying to be minimalistic and have only nesessary (widely used) functionality.

Not quite $foreach_r, but adjacent. I have abused of compile time loops on a few projects, for example on my kernel project I generate 256 ISR stubs via an ASM macro compile-time loop. In plain C or C3, I’d have to spell each function by hand.

But i understand that it clashes with the simple language philosophy.

So even though I could absolutely use this feature, I get why it might not fit the language’s goals.

carlosdaniel26 avatar Dec 08 '25 03:12 carlosdaniel26

@carlosdaniel26 is reverse iteration required explicitly? Is not $for sufficient?

lerno avatar Dec 15 '25 23:12 lerno