News for hackers. Stuff that matters.
Re:A Review of the Zig Programming Language (Using Advent of... by kzrdude on Monday December 27, 2021 @11:41AM (#29703968)
In "The Good" section, the author says there are only while loops and no for.. but apparently there is a for, now I'm unsure what it means. Is `for` a function?
Re:A Review of the Zig Programming Language (Using Advent of... by firethief on Monday December 27, 2021 @12:06PM (#29704256)
`for` is a foreach. If you want to increment a number through a range like a typical C `for`, you have to use a `while` loop. I don't really see the draw.
Re:A Review of the Zig Programming Language (Using Advent of... by dnautics on Monday December 27, 2021 @01:42PM (#29705366)
man if I were andrew I'd just rename for to "foreach", because this is a huge complaint and source of confusion.
Re:A Review of the Zig Programming Language (Using Advent of... by kzrdude on Monday December 27, 2021 @02:01PM (#29705594)
Seems fine to me. Rust has a "foreach" which is named for, working ok. Of course Rust has ranges as iterators, so it's not necessarily noticed that "there is no numerical for" but it works.
Re:A Review of the Zig Programming Language (Using Advent of... by masklinn on Tuesday December 28, 2021 @07:39AM (#29713183)
> Rust has a "foreach" which is named for, working ok.

Also ruby / python.

Don't see the point of a C-style for loop in a modern language, reusing the keyword is perfectly sensible (even more so as many which have both use the same keyword).

C# actively weirds me out every time from having both for and foreach, complete waste of brainspace.

Re:A Review of the Zig Programming Language (Using Advent of... by anonymoushn on Tuesday December 28, 2021 @07:04AM (#29712935)
It seems fine to just delete it if it's only ever going to work on slices and arrays