lightpanda-io / zig-js-runtime

Add a JS runtime in your Zig project
https://lightpanda.io
Apache License 2.0
16 stars 0 forks source link

use const for unmutated var #152

Closed krichprollsch closed 10 months ago

krichprollsch commented 10 months ago

Thanks to zig 0.12 for automatic detection

Relates to https://github.com/Browsercore/project/issues/93

francisbouvier commented 10 months ago

A lot of them are from a dereferencing pattern, const x = alloc.create(T); x.* = y;. I thought that in that case var was mandatory, as we are changing the value afterwards. It seems it's not. Good to know, thanks.

krichprollsch commented 10 months ago

A lot of them are from a dereferencing pattern, const x = alloc.create(T); x.* = y;. I thought that in that case var was mandatory, as we are changing the value afterwards. It seems it's not. Good to know, thanks.

AFAIK in const x when x is a pointer, the const means you can't change the address you point to. But you can change the pointed value itself.