News for hackers. Stuff that matters.
Re:Easy Interfaces with Zig 0.10.0 by encryptluks2 on Thursday November 17, 2022 @04:09AM (#33636564)
I want to like Zig but after trying a couple programs it has a few annoying nuances. I believe you can't use tabs which is overly opinionated and the odd print requirement to use empty brackets is overly verbose.
Re:Easy Interfaces with Zig 0.10.0 by frou_dh on Thursday November 17, 2022 @06:05AM (#33637327)
Something I found eyebrow-raising is that the type of the expression expected in the parenthesised part of an `if () { ... }` actually changes based on what syntax is used on an `else` line that comes later.
Re:Easy Interfaces with Zig 0.10.0 by eatonphil on Thursday November 17, 2022 @10:19AM (#33640061)
I haven't seen that yet. Could you give an example?
Re:Easy Interfaces with Zig 0.10.0 by frou_dh on Thursday November 17, 2022 @10:51AM (#33640658)
IIRC in the following, the expected type of `x` in B stops being bool (but I no longer have a Zig env set up so I can't test it).

    # A
    if (x) {
        ...
    } else {
        ...
    }

    # B
    if (x) {
        ...
    } else |y| {
        ...
    }
Re:Easy Interfaces with Zig 0.10.0 by hansvm on Thursday November 17, 2022 @11:40AM (#33641469)
That looks right. If/else is overloaded as doing the normal thing with bools by default, and if you try to capture something exceptional with `else |y|` then the type of `x` is inferred to be something capable of such a capture -- optionals or error unions.
Re:Easy Interfaces with Zig 0.10.0 by frou_dh on Thursday November 17, 2022 @11:52AM (#33641713)
In a statically typed language, this specifically comes off to me as an artificial way to keep the total number of keywords down.
Re:Easy Interfaces with Zig 0.10.0 by stephc_int13 on Thursday November 17, 2022 @06:55AM (#33637730)
And all the dots.
Re:Easy Interfaces with Zig 0.10.0 by trgt on Thursday November 17, 2022 @12:10PM (#33642066)
Zig 0.10.0 allows tabs. I think 0.9.1 also allowed, but I'm not 100% sure.
Re:Easy Interfaces with Zig 0.10.0 by encryptluks2 on Friday November 18, 2022 @02:04AM (#33651324)
When I use tabs I get "./fizzbuzz.zig:4:1: error: invalid character: '\t'"
Re:Easy Interfaces with Zig 0.10.0 by pverghese on Friday November 18, 2022 @08:34AM (#33654371)
I think any text editor can convert tabs to spaces. I've never had this issue for any number of languages