Re: "cannot coerce inexact literal to fixnum"

Al <[email protected]>
Newsgroups gmane.lisp.scheme.chicken
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.