2 ms·
"Null" is not used in "proper" V. It's not a keyword assigned to any variables, outside of unsafe, and even that is strongly discouraged. Additionally, all vari
by baranul 1y ago
"Null" is not used in "proper" V. It's not a keyword assigned to any variables, outside of unsafe, and even that is strongly discouraged. Additionally, all variables in V have to be initialized with some value and the required memory (which leads to the error from cap being set to 0).
V can compile to C, including native (still in development) and other languages (WASM, JavaScript...), so depending on what someone is doing they can see related error messages. Additionally, there is the circumstance of keeping compatibility with other languages. This is why V has "nil", which is explained in the documentation, but its their objective to eliminate or contain its usage to only unsafe.
From their documentation- "Zero-value references, or nil pointers, will NOT be supported in the future...". Users of V would be familiar with the circumstances and context, to include seeing examples of proper usage.
- theamk 1y agoI have no objection to Vlang having "null", after all many languages have it. My problem is the outright lies on the front page. Someone who is looking into Vlang might actually believe what's written on the front page, spend some time learning language, and come up disappointed. So I am saving them some time by warning them in advance. And no, if you that using null is V is "improper", this still means V has nulls. If the it will not have nulls "in the future", it means it still has nulls today. The front page does not mention any "future" part. And mentioning that you cannot assign it to any variables outside of "unsafe" is outright wrong.. It works just fine, it's just spelled differently (as "voidptr(0)"). Try it yourself in playground: ptr := &int(voidptr(0)); println(*ptr); The thing is, there are plenty of languages without "null" - Rust of course, but also much more "conventional" languages like Kotlin and Swift. So we know what language-without-nulls looks like - there are nullable and non-nullable pointer-things (they may be called using different terms), they are distinct types, and you need a special ceremony to access nullable pointer-things where you specify what to do if the value is null/missing. Vlang does not have anything like that, and it's trivially easy to get the null pointer (either intentionally or from trivial programming error) in safe code.