#Where are functions like @panic located?

1 messages · Page 1 of 1 (latest)

craggy barn
#

Obviously every function has an implementation, so where are functions like these implemented? Inside which file? And how can we contribute more such functions?

thick sorrel
#

@panic specifically calls std.builtin.default_panic or an exposed panic handler in root

#

Others are kinda scattered. You can find some in src/Sema.zig

craggy barn
#

how about if. Icontribute a function like this:

pub fn swap(x: T, y: T) [2]T {
    return [2]T{x, y};
}

or

pub fn swap(x: T, y: T) void {
    const tmp = a.*;
    a.* = b.*;
    b.* = tmp;
}
thick sorrel
#

I doubt it would be accepted, since std.mem.swap exists

craggy barn
#

do you think an @swap() function makes sence?

amber spindle
vivid canyon
amber spindle
#

or sometimes for things that can be much better optimized as a builtin than as userspace

vivid canyon
#

ye

craggy barn
#

Thanks a lot everyone

thick sorrel
#

It's good that you were willing to be the change you wanted to see, though