|
From: | Felix Winkelmann |
Subject: | Re: [Chicken-users] <inexact> and <exact> |
Date: | Wed, 11 Aug 2004 07:47:47 +0200 |
User-agent: | Opera M2/7.52 (Win32, build 3834) |
Hello, I am working with a C++ library which has methods that take a 'double'. Using declare(full_specialization, yes) I can get TinyCLOS to recognize method calls when the parameter is of the form 1.0001, but not if it is just '1' - I get an error looking for an <exact> method. This seems supported by R5RS saying that exactly one of exact? andinexact? is true, but how can I get my methods to recognized exact numbersas well? (I don't really want to define an <exact> case for each one..)
I assume you really require full_specialization, correct? Is it possible for you to change the original code? Because then you could use the "type" pseudo declaration: #>! __declare(full_specialization,yes) __declare(type, "number;double;exact->inexact") class Foo { public: number foo(number n) { printf("[%g]\n", n); return n * 2; } }; <# (print (foo (make <Foo>) 123.4)) ; prints 123.4 and 246.8 But... provided, you use a patched version of easyffi.scm. ;-) (mapping foreign types to classes didn't honor user-defined types) I'll submit a patch tonight. cheers, felix
[Prev in Thread] | Current Thread | [Next in Thread] |