* kawa java.util.Random
@ 2015-10-30 18:37 Debabrata Pani
2015-10-30 18:41 ` Debabrata Pani
0 siblings, 1 reply; 3+ messages in thread
From: Debabrata Pani @ 2015-10-30 18:37 UTC (permalink / raw)
To: kawa
While using java random numbers, I am getting the following warning
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: kawa java.util.Random
2015-10-30 18:37 kawa java.util.Random Debabrata Pani
@ 2015-10-30 18:41 ` Debabrata Pani
2015-10-30 18:51 ` Per Bothner
0 siblings, 1 reply; 3+ messages in thread
From: Debabrata Pani @ 2015-10-30 18:41 UTC (permalink / raw)
To: kawa
Sorry, the previous mail was sent even before I could complete it.
To continue..
While using java random numbers, I am getting the following warning
#|kawa:43|# (define xx (java.util.Random (java.lang.System:currentTimeMillis)))
#|kawa:44|# xx
java.util.Random@5bfbf16f
#|kawa:45|# (xx:nextInt 10)
/dev/stdin:45:2: warning - no known slot 'nextInt' in java.lang.Object
8
#|kawa:46|# xx
This is observable in both kawa 2.1 and kawa 2.0
Is this a known/expected behavior ?
Regards,
Debabrata Pani
On Sat, Oct 31, 2015 at 12:07 AM, Debabrata Pani
<debabrata.pani@gmail.com> wrote:
> While using java random numbers, I am getting the following warning
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: kawa java.util.Random
2015-10-30 18:41 ` Debabrata Pani
@ 2015-10-30 18:51 ` Per Bothner
0 siblings, 0 replies; 3+ messages in thread
From: Per Bothner @ 2015-10-30 18:51 UTC (permalink / raw)
To: kawa
On 10/30/2015 11:40 AM, Debabrata Pani wrote:
> Sorry, the previous mail was sent even before I could complete it.
>
> To continue..
>
> While using java random numbers, I am getting the following warning
>
> #|kawa:43|# (define xx (java.util.Random (java.lang.System:currentTimeMillis)))
> #|kawa:44|# xx
> java.util.Random@5bfbf16f
> #|kawa:45|# (xx:nextInt 10)
> /dev/stdin:45:2: warning - no known slot 'nextInt' in java.lang.Object
> 8
> #|kawa:46|# xx
>
> This is observable in both kawa 2.1 and kawa 2.0
>
> Is this a known/expected behavior ?
The reason is the Kawa compiler can't know that you won't later do
something like:
(set! xx "foo")
so it can't safely infer the type. (It could in the case where nextInt is
called directly at the top-level, but in the general case if the nextInt
call is inside a function, which might be called at a later time.)
Do any one of:
(define-constant xx (java.util.Random (java.lang.System:currentTimeMillis)))
(! xx (java.util.Random (java.lang.System:currentTimeMillis)))
(define xx ::java.util.Random (java.util.Random (java.lang.System:currentTimeMillis)))
Using '!' is more-or-less equivalent to define-constant.
I'm considering changing Kawa so that the type of xx in the plain-define case
would be 'dynamic' rather than 'java.lang.Object'. That will suppress the warning.
Alternatively, this could be part of the "interactive mode" improvements
I'm also considering.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-30 18:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-30 18:37 kawa java.util.Random Debabrata Pani
2015-10-30 18:41 ` Debabrata Pani
2015-10-30 18:51 ` Per Bothner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).