Hacker News new | past | comments | ask | show | jobs | submit login

I'd have preferred a `fun` (or `fn, if you insist on 2 characters) instead of the Haskell-esque double colon `::` in function definitions to make parsing them easier. And the semicolon after `case` is irritating for me too. But `foo := bar` for a type-less `foo: TYPE = bar` is too much parser-friendly syntax and inconsistent with using a double colon `::` for function types and struct definitions. And inconsistent with using just the colon in `foo: TYPE`.

How do nested for-loops work, if `it` names the current iterator?

     for particles {
        // Inside for loops the "it" object is the iterator for the current object.
        particle_left := view_left \* it.particle_size;
     }



Just like every language that implicitly names the current value of the iterator:

- It's the innermost iterator that takes priority

- You are encouraged to name your iterators if you do so (for particles { part -> part.velocity } )

- Compiler throws warnings if you shadowed names.


> Just like every language that implicitly names the current value of the iterator

Oh, i didn't know that there are any.

It would be a good idea to add the naming explicitly to the Wiki entry of loops: https://jai.community/t/loops/147, I've just found it buried in the `remove` section.

Btw. in for-loops the colon `:` is used inconsistently again, this time for naming the iterator (`foo` in this example:) `for foo: VALUES { ... }`.


>Oh, i didn't know that there are any.

Plenty! Although, it's not limited to iterators: most languages that have first class lambdas/closures behave this way. Kotlin has `it` as the default parameter of any lambda (but only accepts it for single parameter lambdas, two parameters and you need to name them:

`fun <T, U> Collection<T>.map(block: (T) -> U): Collection<U>`

is called like so:

`listOf(1, 2, 3).map { it * it }`

Swift has $0, $1

>Btw. in for-loops the colon `:` is used inconsistently again, this time for naming the iterator (`foo` in this example:) `for foo: VALUES { ... }`.

Sorry, Jonathan Blow doesn't believe in such silly things as "compiler research" nor "programming language research". Jai gets built by piling up crap on top of crap.


Thanks, and yes, I didn't think about closures.

Talking about closures, I also don't know why Jai needs explicit capture lists. In C++ and Rust I understand the need for them, because you have various ways to pass them into the lambda, but Jai doesn't seem to care, at least in the examples at https://github.com/BSVino/JaiPrimer/blob/master/JaiPrimer.md.... To be honest, I also don't see how this is different from just writing the function definition by hand, just in more than one step and you have to throw away the intermediate versions?

Btw. I just replied to say that I really like your username, I have noticed it just now :)


+1,fun, fn, have obvious visual effects




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: