top | item 35324706

(no title)

0x37 | 2 years ago

I don't usually like participating in bikeshedding, but the @ annotation feels like PHP's $ to me in that I don't see why it needs to exist. The language design could've easily just left that out and I don't think anything would be lost.

Other than that, I'm definitely excited for Zig as a potential C++ replacement.

discuss

order

ptato|2 years ago

Built-in names are essentially reserved words, and there are dozens of them. The @ prefix ensures you don't step on user's variable names, and that you can add new built-ins without making breaking changes.

andrepd|2 years ago

Why aren't they simply namespaced, like `core.some_function`?

kristoff_it|2 years ago

> I don't see why it needs to exist

The symbol namespaces builtins, as those are the only identifiers that aren't declared in the file (either directly or by using `@import`).

tialaramex|2 years ago

Although namespacing them keeps them out from under a programmer's feet, which is a significant benefit, it does seem like this would make it harder to find stuff. @cmpxchgStrong, @wasmMemorySize and @embedFile are completely unrelated, but since they're all builtins they're neighbours.

throwawaymaths|2 years ago

one side benefit is that at lot of @ code is "dangerous shit" so it draws your eye during code review. You will want to code review the "dangerous shit" that GPT-5 gives you.