Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One thing that I've found really useful is being able to annotate o pointer's alignment. I'm working on an interpreter, and I'm using tagged pointers (6 bits), so the data structure needs to have 128 byte alignment. I can define a function like `fn toInt(ptr: *align(128) LongString) u56` and the compiler will track and enforce the alignment.

You might also find some of the builtin functions interesting as well[1], they have a lot of really useful functions that in other languages are only accessible via the blessed stdlib, such as @addrSpaceCast, @atomicLoad, @branchHint, @fieldParentPtr, @frameAddress, @prefetch, @returnAddress(), and more.

[1] https://ziglang.org/documentation/master/#Builtin-Functions



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: