<div class="gmail_quote">[Possibly duplicate post, sorry]</div><div class="gmail_quote"><br></div><div class="gmail_quote">Hi Alessio,<div><br></div><div> Thanks for the quick and detailed response.<br><br><div class="gmail_quote">
<div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Interesting! I'm answering because I wrote the current (incomplete)<br>
version of jnew-runtime-class. Just FYI, you can find some notes about<br>
it at <<a href="http://trac.common-lisp.net/armedbear/wiki/JavaFfi/RuntimeClass" target="_blank">http://trac.common-lisp.net/armedbear/wiki/JavaFfi/RuntimeClass</a>>.<br></blockquote><div><br></div></div><div>I read that, and that did help a lot in understanding the new code. BTW, regarding the constructors, shouldn't you be able to define a method entry with name as :constructor and have that work? From looking at the function map-method-name in jvm-class-file.lisp, but not actually tested it yet.</div>
<div class="im">
<div><br></div><div> </div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>
</div>What I wanted to achieve is to have methods that can be:<br>
* arbitrary functions, including closures<br>
* possibly redefined after the class has been loaded. Redefinition is<br>
possible by using symbols as method implementations.<br>
<br>
There's also a hidden goal that is to keep the implementation simple<br>
enough, and compiling Lisp code to the body of methods in an arbitrary<br>
class is not easy at the moment.<br>
<br>
What explicitly is NOT a requirement is to have the generated class be<br>
independent from ABCL (the methods are implemented in Lisp and will<br>
always need runtime support). So, no matter how you arrange things,<br>
you will never be able to distribute your class without abcl.jar. Note<br>
that it is the same for Clojure, Scala, Groovy, etc.<br>
<br>
I don't know specifically how Hadoop works, but, as I see things, you need to<br>
1. provide abcl.jar + your class to it<br>
2. have Hadoop execute enough code to load ABCL and initialize your class.<br>
<br></blockquote><div><br></div><div><br></div></div><div>Right. This is the same in clojure where I implemented something similar, but the language was unfamiliar and the way to actually call compile felt clunky, but some of that surely was simply unfamiliarity.</div>
<div><br></div><div>So what I want to do is the following:</div><div>1. have abcl.jar and generated_filename_with_method_implementations.lisp in the classpath</div><div>2. Do the jvm equivalent of the following java code:</div>
<div><br></div><div>Interpreter interp = Interpreter.createInstance();</div><div>interp.eval("(load \"generated_filename_with_method_implementations.lisp\")");</div><div><br></div><div>in the static initialization block of the class.</div>
<div class="im">
<div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Now, probably the key point is who loads your class.<br>
* if you can arrange to have ABCL load it and pass it to Hadoop, you<br>
should be good with the current design.<br>
* if Hadoop wants to load it by itself from a jar, then yes, you have<br>
to somehow dump the method implementations somewhere and have the<br>
class auto-load them from there when it is initialized.<br>
<br>
For the second case, I propose an intermediate design that is, imho,<br>
simpler than dumping arbitrary forms: special-case the situation when<br>
a method implementation is a symbol. In that case, directly generate<br>
an instruction in the class file to find that symbol in its package<br>
and assign it to the appropriate field. If the implementation of a<br>
method is not a symbol nothing changes. That way, you will still need<br>
to init ABCL before loading your class, but, when all your method<br>
implementations are symbols, the class will be able to initialize<br>
itself without external support. If some methods are proper functions,<br>
instead, the class won't be self-contained, but will need some Lisp<br>
code to be executed to be properly initialized.<br>
<br>
Does it make sense to you? Do you find it acceptable? If yes, I can<br>
give a shot at implementing it, if you want.<br>
<br></blockquote><div><br></div><div><br></div></div><div>This certainly seems reasonable, but I don't understand the bit about "directly generate an instruction to find the package and do the assignement". Do I not need to change the compile infrastructure to get at the jvm representation of the (fdefinition name) ? The code in %jvm-compile (in compiler-pass2.lisp) seems to do the compilation to a (sys::%make-byte-array-output-stream) rather than to arbitrary output-streams. Don't know the reason for this. If this can be changed, we can do this for arbitrary forms, rather than just symbols.</div>
<div><br></div><div>ie, we can compile the relevant forms into classname_methodname.abcl and generate a static method call to Load.load(filename) in the static init block as before, to do the autoloading, and then we will know the LispObject name holding the jmethod and can assign that to the appropriate field as you suggest above.</div>
<div><br></div><div>Other than this (the compile issue), I find this entirely reasonable and would love it if you do implement it.</div><div><br></div><div>much regards,</div><div><br></div><div>Archi</div><div class="im">
<div><br></div>
<div> </div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Peace,<br>
Alessio<br>
<span><font color="#888888"><br>
--<br>
Some gratuitous spam:<br>
<br>
<a href="http://ripple-project.org" target="_blank">http://ripple-project.org</a> Ripple, social credit system<br>
<a href="http://villages.cc" target="_blank">http://villages.cc</a> Villages.cc, Ripple-powered community economy<br>
<a href="http://common-lisp.net/project/armedbear" target="_blank">http://common-lisp.net/project/armedbear</a> ABCL, Common Lisp on the JVM<br>
<a href="http://code.google.com/p/tapulli" target="_blank">http://code.google.com/p/tapulli</a> my current open source projects<br>
<a href="http://www.manydesigns.com/" target="_blank">http://www.manydesigns.com/</a> ManyDesigns Portofino, open source<br>
model-driven Java web application framework<br></font></span></blockquote><div><br></div><div><br></div><div><br></div></div></div></div>
</div><br>