autos2j environment
Matthias Radestock <[email protected]>
| Newsgroups | gmane.comp.java.sisc.user |
|---|---|
| Message-ID | <[email protected]> |
How many of you find it tedious that in s2j one has to define bindings
for java classes, methods and fields before being able to use them? It's
never bothered me that much, but I've had some complaints/requests from
users.
One possible solution is to automatically bind all symbols with a
certain prefix to the appropriate s2j java class, method or field. To
the programmer this feels like having a toplevel environment in which
all java entities are pre-defined. One would be able to write, for
example
(install-autos2j 'j%)
(let ([buf (java-new <j%java.lang.string-buffer>)]
[s (java-new <j%sisc.data.symbol> (->jstring "foo"))])
(j%append buf (:j%symval s))
(:j%symval! s (->jstring "bar"))
(j%append buf (:j%symval s))
(->string (j+to-string buf)))
install-autos2j tells the system what prefix to recognise as possible
s2j binding. The function can be called multiple times, with different
prefixes or the same prefix. However, it will not accept overlapping
prefixes.
Comments? Suggestions?
Matthias
PS: I actually have all of the above working as a prototype, involving a
few dozen lines of Scheme code that hook an s2j proxy into the
environment chain. There are quite a few design options for implementing
this properly. I will discuss these on sisc-devel if people like the
overall idea.