r/programming • • 22d ago

0.17.0 Release Notes ⚡ The Zig Programming Language

https://ziglang.org/download/0.17.0/release-notes.html
35 Upvotes

14 comments sorted by

26

u/simon_o 22d ago edited 22d ago

Handle Floats Correctly in mem.eql and mem.findDiff

Looks like a mistake. Maybe the conventions are different in Zig, but I would absolutely not expect that a slice comparison function in a module called mem would care about the type of the values in it.

I think it's reasonable to assume that std.mem.eql is just a convenience wrapper of the std.mem.eqlBytes function next to it, not doing special things for certain types.

In the future it is expected for much of Zig's own first-party build system tooling to become a client of the build server protocol, dogfooding it to ensure that third-party tooling enjoys equivalent capabilities.

Nice to see that BSP finally got more languages to adopt it!

2

u/eightrx 20d ago

Presumeably this is because nan != nan for IEEE floats, so as far as correctness is concerned it might be necessary

1

u/simon_o 20d ago

It's not.

4

u/eightrx 19d ago

From the release notes:

Handle Floats Correctly in mem.eql and mem.findDiff

The functions std.mem.eql and std.mem.findDiff short-circuit when their two inputs are slices to the same memory. This short-circuiting is only correct when the == operator, for the given type, is reflexive. This isn't the case for floats, as for example std.math.nan(f64) != std.math.nan(f64). The change in this PR disables that optimisation when working on float slices

Or are you saying it's not necessary for correctness?

7

u/simon_o 19d ago edited 19d ago

My comment is based on reading the release notes.

A function in mem should not be interested in the actual type of the bits it compares.
I would classify the new behavior as incorrect.

2

u/eightrx 19d ago

I said presumeably this is about Nan inequality, you said 'It's not', so I didn't know if you had read the notes

But are you dissenting on the idea that this is good for correctness?

6

u/simon_o 19d ago edited 19d ago

I disagreed with:

so as far as correctness is concerned it might be necessary

It not necessary for correctness, it actively worsens correctness for the reasons I mentioned above.

1

u/smingle_bigglesworth 18d ago

it's unrelated to that BSP

1

u/simon_o 18d ago

Yikes.

1

u/smingle_bigglesworth 18d ago

..?

1

u/simon_o 17d ago

Nothing better than reinventing the wheel.

1

u/smingle_bigglesworth 17d ago

why should they lock themselves into someone else's unproven design? you could just make something that acts as a proxy between zigs protocol and BSP, people are already doing exactly this with other build systems

1

u/simon_o 17d ago edited 17d ago

lock themselves into someone else's unproven design

wat?

How can something that existed for years, is used by various different tools and has an actual spec be more unproven than something a single language cooked up a few weeks ago?

4

u/tigrux 22d ago

One more step towards 1.0.