Re: autos2j environment

Matthias Radestock <[email protected]>
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
Alessandro,

thanks for your comments.

"Alessandro Colomba" <[email protected]> writes:

> 1. Would the effect of install-autos2j be limited to the some lexical
> scope? It would be nice to be able to keep the chosen prefixes local
> to a module, for instance.

I considered that approach but can't think of an easy way to do
this. The closest I can get is something along the lines of

  (with-auto-s2j-env j% <body>)

which compiles and executes <body> in an environment that performs the
appropriate s2j lookups. The problem here is that this env is a
child of the toplevel and thus any bindings created by <body> are
created in that env rather than the toplevel.

> 2. Is there any way that something similar could be done with Java
> package names? As in:
>
> (import-java-package |java.lang| jl%)
>
> (let ((buf (java-new <jl%string-buffer>)))
>  ...

That is certainly possible though I doubt it's of much use in the
absence of lexical scoping.

One way to cut down on the verbosity of FQ class names is to introduce a
macro that lets you write s.t. like

  (define-java-classes-in-package (jl% j%java.lang)
     string-buffer
     system
     thread)

which simply expands to

  (define <jl%string-buffer> <j%java.lang.string-buffer>)
  (define <jl%system> <j%java.lang.system>)
  (define <jl%thread> <j%java.lang.thread>)


> 3. This is very minor, but what do you think of a name such as
> (import-autos2j) or the like, since we are, in a sense, importing a
> set of symbols from the outside?

The name 'import' has lexical connotations, and given that, as explained
above, this is not a lexical operation it would be inadvisable to call
it that.


Matthias.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.