This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: problem compiling primitive array references
- From: Per Bothner <per at bothner dot com>
- To: "Hurst, Dave" <DHurst at lisletech dot com>
- Cc: "'kawa at sources dot redhat dot com'" <kawa at sources dot redhat dot com>
- Date: Fri, 07 Jul 2006 09:37:15 -0700
- Subject: Re: problem compiling primitive array references
- References: <9E8A844656C6D9119A780060B0A3897E2A6EED@arcturus.lisletech.com>
Hurst, Dave wrote:
Hello!
I have a function that converts an array of objects returned by a Java
function into a Scheme list. This function works just fine in interpreted
mode. When I try to compile the Scheme, I get an error complaining that
gnu.kawa.reflect.ArrayLength does not implement Externalizable.
This seems to have been fixed sometime between kawa-1.7 and kawa-1.7.90.
But notice this is a symptom of inefficient code: If Kawa is able to
generate efficient bytecode, it won't need to externalize ArrayLength.
Here is example code:
(define (get-aggregation-policy pqm :: <com.lisletech.PolicyQueryManager>)
(let ((ap-get (primitive-array-get <com.lisletech.PolicyNodeType>))
(ap-length (primitive-array-length <com.lisletech.PolicyNodeType>))
(policy-list (PolicyQueryManager:getAggregationPolicy pqm)))
(let collect ((index 0))
(if (< index (ap-length policy-list))
(cons (ap-get policy-list index)
(collect (+ index 1)))
'()))))
The calls to ap-get and ap-length will require run-time reflection.
You might want to define ap-get and ap-length as macros instead.
It might also work to define them as constants:
(define-constant ap-get
(primitive-array-get <com.lisletech.PolicyNodeType>))
However, I haven't tested if this will let ap-get calls be inlined.
The current Kawa SVN has much more convenient ways to access
Java arrays, by the way.
--
--Per Bothner
per@bothner.com http://per.bothner.com/