<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi,<div><br></div><div>I'm not sure I understand the basic problems yet. Why construct Lisp-side mirror classes instead of dispatching directly on Java objects?</div><div>(defmethod foo ((x (jclass "org.comp.Whizzle")))</div><div> (let ((datum (jcall "getWhizzleComponent" x)))</div><div> ...))</div><div><br></div><div>Also, why reconstruct Java methods Lisp-side? Currently, I tend to use abcl as a "top-level scripting layer", without trying to duplicate stuff (including methods) that's already implemented Java-side (the following fragment uses jss for method call notation, although currently I prefer plain jcall again):</div><div><br></div><div><div>(defun piechart ()</div><div> (let* ((data (jnew "org.jfree.data.general.DefaultPieDataset"))</div><div> (chart (jstatic "createPieChart" "org.jfree.chart.ChartFactory"</div><div> ;; check ChartFactory for chart types!</div><div> "Sample Pie Chart" data +true+ +false+ +false+))</div><div> (frame (jnew "org.jfree.chart.ChartFrame" "Test" chart)))</div><div> (#"setValue" data "Category 1" 401)</div><div> (#"setValue" data "Category 2" 227)</div><div> (#"setValue" data "Category 3" 211)</div><div> (#"pack" frame)</div><div> (#"setVisible" frame +true+)))</div></div><div><br></div><div>But I suspect that I'm answering the wrong questions here.</div><div><br></div><div>Rudi</div><div><br><div><div>On Feb 16, 2013, at 11:59, Blake McBride <<a href="mailto:blake@arahant.com">blake@arahant.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">Thanks for the feedback. I'm not sure about that approach because most methods don't share the same name. I'd have to know in advanced which do, which don't, an what the special keys are. This doesn't amount to anything more than name mangling generics. I am still stuck having to know too many special cases. Having, essentially, custom dispatching code in the generics based on argument count and types seems to be the only clean solution I can think of. The problem of course, is that it is a bit difficult to implement - auto generation of this based on Java reflection. I'd love to find an easier solution to implement that doesn't make it hard to use.<div>
<br></div><div>Thanks for the idea!!</div><div><br></div><div>Blake<br>
<br><br><div class="gmail_quote">On Fri, Feb 15, 2013 at 9:40 PM, Vsevolod Dyomkin <span dir="ltr"><<a href="mailto:vseloved@gmail.com" target="_blank">vseloved@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hello Blake,<div><br></div><div>What would you say of the following scheme for variable-argument methods:</div><div><br></div><div>(defgeneric method (object spec &rest &key))</div><div><br>
</div><div>(defmethod method ((object clos-mirror-object) (spec (eql :variantion1)) &rest &key arg1 arg2 &allow-other-keys)</div><div> ...) </div><div><br></div><div>I.e. introducing an additional argument that you can use for dispatching of the same-named methods belonging to one class?</div>
<div><br></div><div>Best</div><div class="gmail_extra"><br clear="all"><div>Vsevolod Dyomkin<div><a href="tel:%2B38-096-111-41-56" value="+380961114156" target="_blank">+38-096-111-41-56</a></div><div>skype, twitter: vseloved</div>
</div>
<br><br><div class="gmail_quote"><div><div class="h5">On Sat, Feb 16, 2013 at 1:54 AM, Blake McBride <span dir="ltr"><<a href="mailto:blake@arahant.com" target="_blank">blake@arahant.com</a>></span> wrote:<br></div>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">
Greetings,<div><br></div><div>I have a large Java app with more than 15K Java classes. I linked it up with ABCL and successfully used it in several places. However, I had a couple of problems that caused me to use ABCL significantly less than I had hoped. I thought I would share my problems and perhaps there might be a helpful suggestion.</div>
<div><br></div><div>Although I don't interface with most of the 15K Java classes, there are still a lot of classes to interface ABCL with. I wrote some lisp code that, through Java reflection, creates CLOS classes that mirror the Java classes I wish to interface with. In CLOS it encapsulates the Java instance, mirrors the class hierarchy, and creates generics to match the Java methods. I found a way to create variable argument generics that feed fixed argument methods in order to handle the fact that similarly named methods can take different arguments across different Java classes.</div>
<div><br></div><div>I ran into two problems that have caused me to use ABCL much less than I'd like to. The first seems like won't be too hard to solve, but the second is something I still need to find a solution to. Remember, I cannot build this interface manually. There are too many classes and methods.</div>
<div><br></div><div>The first problem is that I have Java classes and instances mirrored as CLOS classes and instances. At times it was more convenient (from lisp) to deal with Java objects directly instead of CLOS mirrors. While it was more convenient, it ended up being too confusing. With all these classes, objects, and methods, it was too easy to forget what the heck I was dealing with at any point in the code. I think the only answer to this is to only deal with lisp objects when in lisp. This would avoid the confusion at the cost of wrapping and unwrapping certain Java objects at times - not too bad. I would need to have a way to pack Jeve arguments from Jave when calling Lisp. Doing it in Lisp is a problem because I am back to the confusion of knowing when I am dealing with a Java object and when a lisp object.</div>
<div><br></div><div>The second problem has to do with the fact that a single Java class can use the same method name multiple times with different arguments. Remember, I am using variable argument generics to handle similar Java method names taking different argument across different classes. I still have argument checking because I dispatch to a fixed argument CLOS method. However, I cannot do this within a single class. The first obvious answer is to name mangle the generics. This is too sloppy. The other answer would be to name mangle the methods and have the generic be smart enough to dispatch to the correct method based on the argument number and types (all in CLOS). This would be a lot of work so I thought I might solicit alternative suggestions. Perhaps there is a simple answer that I hasn't come to me.</div>
<div><br></div><div>Thanks.</div><span><font color="#888888"><div><br></div><div>Blake McBride</div><div><br></div>
</font></span><br></div></div>_______________________________________________<br>
armedbear-devel mailing list<br>
<a href="mailto:armedbear-devel@common-lisp.net" target="_blank">armedbear-devel@common-lisp.net</a><br>
<a href="http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel" target="_blank">http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div>
_______________________________________________<br>armedbear-devel mailing list<br><a href="mailto:armedbear-devel@common-lisp.net">armedbear-devel@common-lisp.net</a><br>http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel<br></blockquote></div><br></div></body></html>