zig build -Dskip-install-lib-files
Measurements taken on:
- Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
- 0.10.0-dev.2381+39ebfedd2
[nix-shell:~/Downloads/zig/build]$ ./zig fmt --ast-check ../src/ ../lib/std/ | |
as_node: 571082 | |
dbg_stmt: 325704 | |
int: 266542 | |
extended: 212003 | |
param_type: 185337 | |
int_big: 177048 | |
call: 138602 | |
field_call_bind: 105334 | |
decl_val: 99774 |
map: std.AutoHashMapUnmanaged(void, void), | |
items: std.MultiArrayList(Item), | |
extra: std.ArrayListUnmanaged(u32), | |
strings: std.ArrayListUnmanaged(u8), | |
const InternArena = @This(); | |
const std = @import("std"); | |
const Allocator = std.mem.Allocator; | |
const KeyAdapter = struct { |
export fn entry() bool { | |
doTheTest() catch return false; | |
return true; | |
} | |
fn doTheTest() !void { | |
var x1: u8 = 42; | |
const t1 = .{ x1, 56, 54 }; | |
var arr1: [3]u8 = t1; | |
_ = arr1[0]; |
[14:41:12] <waddlesplash> Zig seems cool but you don't seem to be about the RAII that we love so much :-p | |
[14:47:25] <andrewrk> anyway I won't come in here trying to convince anyone to switch languages or coding styles :) | |
[14:47:44] <waddlesplash> in Haiku ... C++ virtual inheritance and RAII objects mean that the code can much more clearly communicate what it is trying to do at the same time it is actually doing it | |
[14:48:02] <andrewrk> I do think that there is a misunderstanding that we don't care about RAII principles in zig though. I mean yeah you have to manually `defer cleanup();` but the coding model is the same | |
[14:48:15] <waddlesplash> but what happens if you decide you don't want to clean something up? | |
[14:48:21] <waddlesplash> for instance we have a very common paradigm in Haiku: | |
[14:49:35] <waddlesplash> thing* whatever = allocate_memory_or_something(); | |
[14:49:35] <waddlesplash> MemoryDeleter<thing> whateverDeleter(whatever); | |
[14:49:36] <waddlesplash> if (error) return error; /* whatever is delete |
I have an object file created by LLVM:
$ readelf -s test.o
Symbol table '.symtab' contains 8 entries:
Num: Value Size Type Bind Vis Ndx Name
0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
1: 0000000000000000 0 FILE LOCAL DEFAULT ABS test
2: 0000000000000010 22 FUNC LOCAL DEFAULT 2 start.callMain2
const std = @import("std"); | |
const expect = std.testing.expect; | |
test "example" { | |
var x: usize = 0; | |
x += checkSize(i32); | |
x += checkSize(bool); | |
try expect(x == 5); | |
} |
const std = @import("std"); | |
const mem = std.mem; | |
const Foo = struct { | |
string_bytes: std.ArrayListUnmanaged(u8), | |
/// Key is string_bytes index. | |
string_table: std.HashMapUnmanaged(u32, void, IndexContext, std.hash_map.default_max_load_percentage), | |
}; | |
const IndexContext = struct { |
[nix-shell:~/Downloads/zig/build-release]$ ./zig build-exe test.zig -OReleaseFast | |
[nix-shell:~/Downloads/zig/build-release]$ ls -hl ../lib/std/special/compiler_rt/udivmod{t,d}i4_test.zig test.zig | |
-rw-r--r-- 1 andy users 1.9M May 10 21:29 ../lib/std/special/compiler_rt/udivmoddi4_test.zig | |
-rw-r--r-- 1 andy users 9.8M May 10 21:29 ../lib/std/special/compiler_rt/udivmodti4_test.zig | |
-rw-r--r-- 1 andy users 1.2K Jul 3 16:46 test.zig | |
[nix-shell:~/Downloads/zig/build-release]$ ./test test.zig | |
tokenizer: 25 MiB/s |
if (instruction->operand != nullptr && | |
instruction->operand->value->type->id != ZigTypeIdErrorSet && | |
instruction->operand->value->type->id != ZigTypeIdErrorUnion) | |
{ | |
// Reset error return trace index. | |
bool is_llvm_alloca = false; | |
LLVMValueRef err_ret_trace_ptr = get_cur_err_ret_trace_val(g, instruction->base.base.scope, &is_llvm_alloca); | |
if (err_ret_trace_ptr != nullptr) { | |
size_t index_field_index = g->stack_trace_type->data.structure.fields[0]->gen_index; | |
LLVMValueRef index_field_ptr = LLVMBuildStructGEP(g->builder, err_ret_trace_ptr, (unsigned)index_field_index, ""); |