ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.83k stars 2.55k forks source link

doc/langref: document the blank identifier #11087

Open perillo opened 2 years ago

perillo commented 2 years ago

The Go Language Specification documents the _ identifier, called the blank identifier: https://go.dev/ref/spec#Blank_identifier.

However the Zig Language Reference only says:

"The `_ = C;` syntax is a no-op reference to the identifier `C`"

inside an example.

Vexu commented 2 years ago

It's also documented in the paragraph above the example:

The code sample below uses the std.testing.refAllDecls(@This()) function call to reference all of the containers that are in the file including the imported Zig source file. The code sample also shows an alternative way to reference containers using the _ = C; syntax. This syntax tells the compiler to ignore the result of the expression on the right side of the assignment operator.

Related #4164.