From 8b720543f538862796fec0ff6b7ea12cb140bf0f Mon Sep 17 00:00:00 2001 From: Zuhaitz Méndez Fernández de Aránguiz Date: Sun, 25 Jan 2026 14:38:28 +0000 Subject: Fix for #90 --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 9159ea2..e87b8ea 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,7 @@ Join the discussion, share demos, ask questions, or report bugs in the official - [Const Arguments](#const-arguments) - [Default Arguments](#default-arguments) - [Lambdas (Closures)](#lambdas-closures) + - [Raw Function Pointers](#raw-function-pointers) - [Variadic Functions](#variadic-functions) - [5. Control Flow](#5-control-flow) - [Conditionals](#conditionals) @@ -319,6 +320,24 @@ var double = x -> x * factor; // Arrow syntax var full = fn(x: int) -> int { return x * factor; }; // Block syntax ``` +#### Raw Function Pointers +Zen C supports raw C function pointers using the `fn*` syntax. This allows seamless interop with C libraries that expect function pointers without closure overhead. + +```zc +// Function taking a raw function pointer +fn set_callback(cb: fn*(int)) { + cb(42); +} + +// Function returning a raw function pointer +fn get_callback() -> fn*(int) { + return my_handler; +} + +// Pointers to function pointers are supported (fn**) +var pptr: fn**(int) = &ptr; +``` + #### Variadic Functions Functions can accept a variable number of arguments using `...` and the `va_list` type. ```zc -- cgit v1.2.3