chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] Re: make check failing


From: Peter Bex
Subject: Re: [Chicken-hackers] [PATCH] Re: make check failing
Date: Fri, 4 Jan 2013 23:58:33 +0100
User-agent: Mutt/1.4.2.3i

On Fri, Jan 04, 2013 at 11:39:51PM +0100, Felix wrote:
> > 
> > I'm thinking bugs like indexing a pixel or a database record at position
> > 1.5 due to a mistaken offset calculation.  I've made mistakes like that
> > in the past and would like those to be caught early.  I know we can
> > always add additional checks in wrapper code around the call, but I think
> > that if I'm asking for an integer it makes sense if it complains when
> > passed some fractional value.
> 
> What happens when some integer computation involving fixnums ends up with
> something like 123.0000000001 ? Must I always wrap my arguments in "round" ?

Actually, if you want to write portable code you must, and you must also
wrap it in inexact->exact.  However, since the FFI isn't portable anyway
it won't matter that much, except when if decide to switch to supporting
bignums in core.  When that happens, all code that doesn't round and
convert to exact will break unless we decide to keep this for backwards
compat for a while.  But eventually it'll break.

> This doesn't feel right to me, but I'll push the modified patch, if you 
> insist,
> because I can't bring up more convincing arguments. It just doesn't feel 
> right...

Why doesn't it feel right?  (vector-ref (vector 1 2 3 4) 1.5) shouldn't
work, why then should ((foreign-lambda void do-something int) 1.5),
especially considering vector-ref could reasonably be defined as this:

(lambda (v i) 
  (check-type 'vector v)
  ((foreign-lambda scheme-object C_block_item scheme-object int) v i))?

Cheers,
Peter
-- 
http://sjamaan.ath.cx



reply via email to

[Prev in Thread] Current Thread [Next in Thread]