From efc482a055ea875bea647b69c4aa71d3ed50b8cb Mon Sep 17 00:00:00 2001 From: agra Date: Tue, 19 May 2026 12:01:01 +0300 Subject: [PATCH] ffi 0.8: switch form for the inline-if OS branch (no behavior change) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `inline if OS == { case .macos: ... case .ios: ... else: ... }` is already supported (see library/modules/platform/sdl3.sx:42 and examples/38-build-config.sx:30). Cleaner than the chained `inline if OS == .a; inline if OS == .b; ...` form the prior commit used. Same expected output — only the macOS arm survives codegen on the host. Snapshot unchanged. --- examples/ffi-08-foreign-in-method.sx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/ffi-08-foreign-in-method.sx b/examples/ffi-08-foreign-in-method.sx index a0bf12f..afa9834 100644 --- a/examples/ffi-08-foreign-in-method.sx +++ b/examples/ffi-08-foreign-in-method.sx @@ -56,15 +56,14 @@ main :: () -> s32 { adder := make_adder(100); print("closure(5) = {}\n", adder(5)); - // 4. inline if OS branch — only one platform's call actually emits - inline if OS == .macos { - print("inline if macos = {}\n", ffi_method_helper(7)); - } - inline if OS == .ios { - print("inline if ios = {}\n", ffi_method_helper(7)); - } - inline if OS == .linux { - print("inline if linux = {}\n", ffi_method_helper(7)); + // 4. inline if OS branch — only one arm survives codegen on a + // given target. `inline if X == { case ... }` reads cleaner + // than chained `inline if X == .a; inline if X == .b; ...`. + inline if OS == { + case .macos: { print("inline if macos = {}\n", ffi_method_helper(7)); } + case .ios: { print("inline if ios = {}\n", ffi_method_helper(7)); } + case .linux: { print("inline if linux = {}\n", ffi_method_helper(7)); } + else: { print("inline if other = {}\n", ffi_method_helper(7)); } } 0;