Akuli / jou

Yet another programming language
MIT License
11 stars 4 forks source link

Forever loop syntax......? #390

Closed littlewhitecloud closed 1 year ago

littlewhitecloud commented 1 year ago

I just wrote something like this:

import "stdlib/io.jou"

def main() -> int:
    cnt = 0
    flag = True
    for i = 2;;i++:
        for j = 2; j <= i; j++:
            if not flag:
                break
            for k = 1; k < j; k++:
                if i == j * j - k * k:
                    cnt++
                    flag = False
                    break
        flag = True
        if cnt == 2023:
            printf("%d", i)
            break
    return 0

I think

for i = 0;;i++: # This is a forever loop!

But

compiler error in file "test.jou", line 6: expected an expression, got ';'

image So, should we add a forever loop syntax...?

Akuli commented 1 year ago

Jou is explicit: if you want the condition to always be True, you should write True. So for i = 2; True; i++.

littlewhitecloud commented 1 year ago

thanks