RodrigoDornelles / 3bc-lang

Low-level language, tiny virtual machine, minimal runtime, intermediate representation, embeddable, easy for beginners. (Friendly Punched cards)
https://3bc-lang.org
GNU General Public License v3.0
232 stars 25 forks source link

remove all 'for' loops from source code #344

Closed RodrigoDornelles closed 1 year ago

RodrigoDornelles commented 1 year ago

by the ANSI standard the first field of for ends up not being used to instantiate variables, besides using while would be something simpler and more readable to maintain.

before

int i = 0;

for (; i < sizeof(any); i++) {
   /** code **/
}

after

int i = 0;

while(i < sizeof(any)) {
   /** code **/
   i += 1;
}
ramyashreeshetty commented 1 year ago

Hey, where exactly do you want these changes to be done?

RodrigoDornelles commented 1 year ago

Hey, where exactly do you want these changes to be done?

Hi @ramyashreeshetty !

for all the source code, keep only do while and while

if you want to contribute just replace each for with a while, and keep the indentation for the linter to approve.

Yugal41735 commented 1 year ago

Hello, @RodrigoDornelles is this issue still active?

RodrigoDornelles commented 1 year ago

Hello, @RodrigoDornelles is this issue still active?

Yes.

Yugal41735 commented 1 year ago

So, for this issue I basically have to just replace for with while, and where exactly I had to do this? Like is there any specific file that you could point to? @RodrigoDornelles

RodrigoDornelles commented 1 year ago

So, for this issue I basically have to just replace for with while, and where exactly I had to do this? Like is there any specific file that you could point to? @RodrigoDornelles

all there´s!

Yugal41735 commented 1 year ago

So, like do I have to visit every single file, and if there's a for loop present then I have to replace it with while? @RodrigoDornelles

RodrigoDornelles commented 1 year ago

So, like do I have to visit every single file, and if there's a for loop present then I have to replace it with while?

browse the code or use a search tool, all sources are in the src/ path, just apply a similar iteration to for() using while() keeping the initial behavior.

Yugal41735 commented 1 year ago

@RodrigoDornelles I had created the pr regarding the same, you could review it.

RodrigoDornelles commented 1 year ago

I had created the pr regarding the same, you could review it.

Tanks!

I've reviewed it, if u make some small changes I'll run the automatic tests to merge.