|
From: | Al |
Subject: | Re: "cannot coerce inexact literal to fixnum" |
Date: | Sat, 24 Feb 2024 19:41:53 +0200 |
User-agent: | Betterbird (Linux) |
On 2024-02-10 16:39, Peter Bex wrote:
Again, these could still be bignums when run on a 32-bit platform (that's why the return type of s32vector-ref is defined as "integer" and not "fixnum")
Hm.. does this mean that using s32vector-ref and -set! always incur typecheck costs, no matter how I type-declare identifiers passed to / from them? And, furthermore, that if replace these with custom-written (foreign-primitive ...)'s, having integer32 args / returns, those would also incur typechecks, and thus never be as efficient as C...?
I've generally taken to avoiding the s32vector-ref/set! builtins. Instead I mostly keep data in SRFI-4 vectors and manipulate it with C-backed foreign-primitives, without ever extracting to fixnums. For example I have things like (s32vector-move1! vec src-idx dst-idx) (copies an element from src-idx to dst-idx). But even for these, I wonder what type the indexes should be declared to minimize typechecks at the interface between C and Chicken...? Perhaps even how to make them inline-able to simple C array ops?
Best, Al
[Prev in Thread] | Current Thread | [Next in Thread] |