pdf文档 The Zig Programming Language 0.2.0 Documentation

2.84 MB 117 页 0 评论
语言
英语
格式
.pdf
评分
3
摘要
0.1.1 | 0.2.0 | 0.3.0 | 0.4.0 | 0.5.0 | 0.6.0 | 0.7.1 | 0.8.1 | 0.9.1 | 0.10.1 | 0.11.0 | 0.12.0 | master Introduction Zig is an open-source programming language designed for robustness, optimality, and clarity. Robust - behavior is correct even for edge cases such as out of memory. Optimal - write programs the best way they can behave and perform. Clear - precisely communicate your intent to the compiler and other programmers. The language imposes a low overhead to reading code. Often the most efficient way to learn something new is to see examples, so this documentation shows how to use each of Zig's features. It is all on one page so you can search with your browser's search tool. The code samples in this document are compiled and tested as part of the main test suite of Zig. This HTML document depends on no external files, so you can use it offline. Hello World hello.zig const std = @import("std"); pub fn main() !void { // If this program is run without stdout attached, exit with an erro var stdout_file = try std.io.getStdOut(); // If this program encounters pipe failure when printing to stdout, e // with an error. try stdout_file.write("Hello, world!\n"); } $ zig build-exe hello.zig $ ./hello Hello, world! Usually you don't want to write to stdout. You want to write to stderr. And you don't care if it fails. It's more like a warning message that you want to emit. For that you can use a simpler API: hello.zig const warn = @import("std").debug.warn; pub fn main() void { warn("Hello, world!\n"); } $ zig build-exe hello.zig $ ./hello Hello, world! Note that we also left off the ! from the return type. In Zig, if your main function cannot fail, you must use the void return type. See also: Values @import Errors Root Source File Values values.zig const std = @import("std"); const warn = std.debug.warn; const os = std.os; const assert = std.debug.assert; pub fn main() void { // integers const one_plus_one: i32 = 1 + 1; warn("1 + 1 = {}\n", one_plus_one);...
The Zig Programming Language 0.2.0 Documentation 第2页
The Zig Programming Language 0.2.0 Documentation 第3页
下载文档到本地,方便使用
共 117 页, 还有 5 页可预览, 继续阅读
文档评分
请文明评论,理性发言.