buzz-language / buzz

👨‍🚀 buzz, A small/lightweight statically typed scripting language
https://buzz-lang.dev
MIT License
1.16k stars 32 forks source link

Zig/C FFI #109

Closed giann closed 10 months ago

giann commented 1 year ago
| `extern struct` because it has to match C ABI
zigdef `
    const Person = extern struct {
        age: usize,
        name: [:0]const u8 name,

        fn hello(self: Person) void;
    };

    fm mul(a: u32, b: u32) u32;
`;

| No different from an buzz object instanciation in syntax
Person person = Person{
    age = 12,
    name = "Joe",
};

person.hello();

print("{person}"); | -> struct Person: 0xef231b

mul(123, 243);

Later: