Hi,
I'm not sure I understand the basic problems yet. Why construct Lisp-side mirror classes instead of dispatching directly on Java objects?
(defmethod foo ((x (jclass "org.comp.Whizzle")))
(let ((datum (jcall "getWhizzleComponent" x)))
...))
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):
(defun piechart ()
(let* ((data (jnew "org.jfree.data.general.DefaultPieDataset"))
(chart (jstatic "createPieChart" "org.jfree.chart.ChartFactory"
;; check ChartFactory for chart types!
"Sample Pie Chart" data +true+ +false+ +false+))
(frame (jnew "org.jfree.chart.ChartFrame" "Test" chart)))
(#"setValue" data "Category 1" 401)
(#"setValue" data "Category 2" 227)
(#"setValue" data "Category 3" 211)
(#"pack" frame)
(#"setVisible" frame +true+)))
But I suspect that I'm answering the wrong questions here.
Rudi
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.
Thanks for the idea!!
Blake
On Fri, Feb 15, 2013 at 9:40 PM, Vsevolod Dyomkin
<vseloved@gmail.com> wrote:
Hello Blake,
What would you say of the following scheme for variable-argument methods:
(defgeneric method (object spec &rest &key))
(defmethod method ((object clos-mirror-object) (spec (eql :variantion1)) &rest &key arg1 arg2 &allow-other-keys)
...)
I.e. introducing an additional argument that you can use for dispatching of the same-named methods belonging to one class?
Best
_______________________________________________
armedbear-devel mailing list
armedbear-devel@common-lisp.net
http://lists.common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel