From b1b4df39abb41a4ae71733e2d139dc70cc71acd8 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 17 Oct 2026 10:13:13 +0200 Subject: zilch: implement callable and promise --- src/zilch/Callable.zig | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/zilch/Callable.zig (limited to 'src/zilch/Callable.zig') diff --git a/src/zilch/Callable.zig b/src/zilch/Callable.zig new file mode 100644 index 0000000..6732c69 --- /dev/null +++ b/src/zilch/Callable.zig @@ -0,0 +1,27 @@ +const mod = @import("root.zig"); +const Options = mod.Options; +const Env = mod.Env; +const AnyFuture = Env.AnyFuture; +const Function = Env.Function; + +const Self = @This(); + +pub inline fn call(self: *Self, env: *Env, args: anytype) AnyFuture { + return env.call(bindings.call, .{ self } ++ args); +} + +pub const bindings = struct { + pub const call: Function = .from( + \\function(target, ...args) { + \\ return target(...args); + \\} + ); +}; + +pub const functions = [_]Function{ + bindings.call, +}; + +pub fn global(tag: @EnumLiteral()) Options.Global { + return .{ .name = @tagName(tag), .type = *Self }; +} -- cgit v1.2.3-70-g09d2