[private]
On 12/15/2010 02:07 AM, John Rose wrote:
I just posted on "Scheme in One Class":
http://blogs.sun.com/jrose/entry/scheme_in_one_class
"Getting at such APIs, randomly and interactively, has been impossible
before JSR 292, at least without statically or dynamically spinning
bytecoded adapters."
Or using reflection. And one might argue that JSR 292 is to some extent
basically "improved and optimizable reflection".
I think most JVM-based languages with a REPL have long been able
to "get at such APIs, randomly and interactively". So I think this
sentence is a bit confusing about exactly what is new.
#|kawa:12|# (define f (java.io.File "Makefile"))
#|kawa:13|# (define p (java.io.FileReader f))
/dev/stdin:13:11: warning - more than one possibly applicable method
'<init>' in java.io.FileReader
candidate: java.io.FileReader
java.io.FileReader.<init>(java.io.FileDescriptor)
candidate: java.io.FileReader java.io.FileReader.<init>(java.io.File)
candidate: java.io.FileReader java.io.FileReader.<init>(java.lang.String)
#|kawa:15|# (set! p (java.io.BufferedReader p))
#|kawa:16|# (write (p:readLine))
/dev/stdin:16:8: warning - no known slot 'readLine' in java.lang.Object
"# Makefile.in generated by automake 1.11.1 from Makefile.am."
The warnings are probably overly conservative (they indicate the compiler
can't determine the specific method at compile-time, so has to use
reflection), but that's a different discussion. They can be turned off
by adding type specifiers:
#|kawa:3|# (define f ::java.io.File (java.io.File "Makefile"))
#|kawa:4|# (define p ::java.io.BufferedReader (java.io.BufferedReader
(java.io.FileReader f)))
#|kawa:5|# (write (p:readLine))
"# Makefile.in generated by automake 1.11.1 from Makefile.am."
(The type specifiers are not needed when evaluating a file, because
then the compiler can know that the variables aren't re-assigned to.)
--
--Per Bothner
[email protected] http://per.bothner.com/
--
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en.