From 3ce8ddfae8335ec2e730b1a184d4aad29038e15d Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 6 Sep 2021 17:25:26 -0700 Subject: ffi: ffi macro uses load-time. A number of functions take an argument which is a ffi type. Typically, this argument is produced using by a ffi-type-compile call which is produced by the ffi macro. But this ffi-type-compile call is invoked at run time, each time such a function is called. A solution for this is to have the ffi macro hoist the compilation to load time. * stdlib/ffi.tl (ffi): Add load-time wrapping to generated expression. * txr.1: Updated correspondence between (ffi ...) form and equivalent (ffi-type-compile form). --- stdlib/ffi.tl | 2 +- txr.1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/ffi.tl b/stdlib/ffi.tl index b9a86b7b..7ca45bf1 100644 --- a/stdlib/ffi.tl +++ b/stdlib/ffi.tl @@ -160,7 +160,7 @@ (ffi-elemsize (ffi-type-compile type))) (defmacro ffi (type) - ^(ffi-type-compile ',type)) + ^(load-time (ffi-type-compile ',type))) (define-accessor carray-ref carray-refset) diff --git a/txr.1 b/txr.1 index 14a2d297..6654abc0 100644 --- a/txr.1 +++ b/txr.1 @@ -79171,7 +79171,7 @@ FFI type expression to the corresponding type object. The following equivalence holds: .verb - (ffi expr) <--> (ffi-type-compile 'expr) + (ffi expr) <--> (load-time (ffi-type-compile 'expr)) .brev .SS* Zero-filled Object Support -- cgit v1.2.3