<html><head></head><body><div class="ydp5337f684yahoo-style-wrap" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
        <div dir="ltr" data-setdir="false"><div><div dir="ltr" data-setdir="false">The jlist-from-list works fine, thank you.</div><br><div><blockquote><blockquote class="ydp361ee9fcyiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span>More
 generally, I think much of the confusion is that a Lisper will enter 
into the FFI with a certain set of assumptions that don't hold. An array
 is a type of list? </span></div></div></div></blockquote><div><br clear="none"></div><div>What's the basis for thinking this?</div></blockquote><div><br></div><div dir="ltr" data-setdir="false">In an earlier message you wrote "<span><span style="font-family:monospace;"><i><span style="font-family:arial, sans-serif;">Since Java.util.List is abstract,  you need to choose a concrete class, such as ArrayList</span>.</i>" <font style="background-color: inherit;" face="Helvetica Neue, Helvetica, Arial, sans-serif">I took this to mean that there was an is-a relationship between Array and List.</font></span></span><br></div><div><br clear="none"></div><blockquote><blockquote class="ydp361ee9fcyiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span><span><span>No Array class? Only specific types of array classes (e.g. array of Int)? </span></span></span></div></div></div></blockquote><div><br clear="none"></div>Not
 following. It would be useful for us if you to unpack how someone would
 come to these conclusions. We could  make the documentation better so 
as to try to avoid the confusion.</blockquote></div><div dir="ltr" data-setdir="false">This came about when I searched for Array classes and a <a href="https://stackoverflow.com/questions/8546500/why-isnt-there-a-java-lang-array-class-if-a-java-array-is-an-object-shouldnt" rel="nofollow" target="_blank">stack overflow discussion</a> seemed to suggest "<span>There <em>are</em> array classes, one per element type used in the program</span>" along with some other information that probably confused me further.</div><div dir="ltr" data-setdir="false"><br></div><div dir="ltr" data-setdir="false">What helped was when I realised that java.lang.list is probably like a lisp <i>sequence </i>and
 although perhaps not a direct superclass, may act like one. I still 
could be wrong, but it helped me conceptualise things enough to 'solve' 
the problem.</div><div dir="ltr" data-setdir="false"><br></div>I've put what I've learned so far into an annotated <a href="https://github.com/Symbolics/Spark.cl/blob/master/hello-world.lisp" rel="nofollow" target="_blank">hello-world.lisp</a>
 on github so that it can be turned into a tutorial when it's finished. 
It's a work in progress, but by the end of the Spark hello world, I hope
 that most of the basics will have been demonstrated. The code is almost
 certainly not yet a good exemplar, and would benefit greatly from a 
review by someone(s) more knowledgeable about ABCL than I.</div><div><br></div></div><div><br></div>
        
        </div><div id="yahoo_quoted_5856739334" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Sunday, July 26, 2020, 6:37:27 AM GMT+8, Alan Ruttenberg <alanruttenberg@gmail.com> wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div id="yiv7393495876"><div><div dir="ltr"><div dir="ltr"><br clear="none"></div><br clear="none"><div class="yiv7393495876gmail_quote"><div class="yiv7393495876gmail_attr" dir="ltr">On Sat, Jul 25, 2020 at 5:15 AM Steven Nunez <<a rel="nofollow" shape="rect" ymailto="mailto:steve_nunez@yahoo.com" target="_blank" href="mailto:steve_nunez@yahoo.com">steve_nunez@yahoo.com</a>> wrote:<br clear="none"></div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
        <div dir="ltr">Thanks Alan. What finally worked is:</div><div dir="ltr"><br clear="none"></div><div dir="ltr"><span>(#"parallelize" *sc* (#"asList" 'Arrays (java:jarray-from-list '(1 2 3 4 5))))</span></div></div></div></blockquote><div><br clear="none"></div><div>Did you try the code I sent to create the list? Here it is rephrased to be analogous to jarrary-from-list</div><div><br clear="none"></div><div><span style="font-family:monospace;">(defun jlist-from-list (list)<br clear="none">  (let ((jlist (jss::new 'arraylist)))<br clear="none">    (loop for el in list<br clear="none">          do (#"add" jlist el))<br clear="none">    jlist))</span></div><div><span style="font-family:monospace;"><br clear="none"></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">I would expect to be able to write </span><br clear="none"></span></div><div><span style="font-family:monospace;"><br clear="none"></span></div><div><div><div style="font-size:13px;"><div><span style="font-family:monospace;">(#"parallelize" *sc* (jlist-from-list '(1 2 3 4 5)))</span></div><div><span style="font-family:monospace;"><br clear="none"></span></div>It would be helpful to know if this doesn't work, as it means there's something I need to learn.<br clear="none"></div></div><span style="font-family:monospace;"></span></div><div> </div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span>But I can't help but think that going from a list to an array to a list is the long way 'round. Is there a better or more idiomatic way to do this?<br clear="none"></span></div></div></div></blockquote><div><br clear="none"></div><div>In this case it's not really going the long way around. #"asList" takes a variable number of arguments - its java method signature is (T... a). JSS doesn't yet know about varargs. The way java implements varags is to actually create a method that takes an <i>array</i> of the arguments, and then when calling the method, add code to pack the arguments into an array. That's what you did - pack the arguments into an array, doing what the java compiler would do.<br clear="none"></div><div> <div><span>See <a rel="nofollow" shape="rect" target="_blank" href="https://stackoverflow.com/questions/21746663/how-does-jvm-implement-the-varargs">https://stackoverflow.com/questions/21746663/how-does-jvm-implement-the-varargs</a></span></div><div><span><br clear="none"></span></div>I'm going to think about how to make varargs work as expected so you could use a more natural syntax<span> <br clear="none"></span></div><div><span style="font-family:monospace;"> (#"parallelize" *sc* (#"asList" 'Arrays 1 2 3 4 5)). <br clear="none"></span></div><div><span><br clear="none"></span></div><div><span>But, as I said, the implementation of jlist-from-list should be adequate. If you can verify that then we can add (an optimized version of) it to abcl.<br clear="none"></span></div><div><br clear="none"></div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span>More generally, I think much of the confusion is that a Lisper will enter into the FFI with a certain set of assumptions that don't hold. An array is a type of list? </span></div></div></div></blockquote><div><br clear="none"></div><div>What's the basis for thinking this?</div><div><br clear="none"></div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span><span><span>No Array class? Only specific types of array classes (e.g. array of Int)? </span></span></span></div></div></div></blockquote><div><br clear="none"></div><div>Not following. It would be useful for us if you to unpack how someone would come to these conclusions. We could  make the documentation better so as to try to avoid the confusion.<br clear="none"></div><div> <br clear="none"></div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span><span><span> I was hoping that this was or could be papered over in a manner similar to CFFI where I barely notice I'm using an external library most of the time. <br clear="none"></span></span></span></div></div></div></blockquote><div><br clear="none"></div><div>Well, that's the intent of JSS (I was the original author of JSS, BTW).  In this case I think you are effectively arguing that we should coerce lisp lists and arrays passed as java arguments to a java equivalent. That's also something I can think about. The downside of this is that sometimes I *want* to pass a cons. I suppose we could provide both, making coercing be the default and add syntax to escape it, so <span style="font-family:monospace;"><br clear="none"></span></div><div><span style="font-family:monospace;">(#"parallelize" *sc* '(1 2 3 4 5))</span></div><div><span style="font-family:monospace;">and</span></div><div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;"><span style="font-family:monospace;">(#"add" jlist (the cons '(1 2 3 4 5)) </span>if I wanted to have an element of  jlist be a cons.</span><br clear="none"></span></div><div><span style="font-family:arial, sans-serif;"><br clear="none"></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">There's still an issue that there are multiple implementations of java's List and we aren't indicating which one is desired. So we'd have to pick a default, like java.util.ArrayList. We'd have to document that if a different type of list was wanted it needs to be created explicitly, ala jlist-to-list. Similarly for arrays. If one writes: <br clear="none"></span></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">(#"myMethod" ob #(1 2 3 4 5)) <br clear="none"></span></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">should it pass a byte array? an integer array? an array of Objects? Again we'd have to choose a default, presumably what jarray-from list does - The array type is the  java type of the first argument. In this case that would be java.lang.Integer. Again I suppose we could add syntax to help.<br clear="none"></span></span></div><div><span style="font-family:monospace;">(#"myMethod" ob (the (array byte) #(1 2 3 4 5)))<br clear="none"></span></div><div><span style="font-family:monospace;"><br clear="none"></span></div><span style="font-family:monospace;"></span></div><div>Any JSS users have an opinion?</div><div class="yiv7393495876yqt8739175055" id="yiv7393495876yqtfd36174"><div><br clear="none"></div><div>Alan<br clear="none"></div><div> <br clear="none"></div><blockquote class="yiv7393495876gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr"><span><span><span></span></span></span></div></div><div id="yiv7393495876gmail-m_7424619492073957442yahoo_quoted_6529422132">
            <div style="font-family:Helvetica, Arial, sans-serif;font-size:13px;color:rgb(38,40,42);">
                
                <div>
                    On Saturday, July 25, 2020, 12:35:08 PM GMT+8, Alan Ruttenberg <<a rel="nofollow" shape="rect" ymailto="mailto:alanruttenberg@gmail.com" target="_blank" href="mailto:alanruttenberg@gmail.com">alanruttenberg@gmail.com</a>> wrote:
                </div>
                <div><br clear="none"></div>
                <div><br clear="none"></div>
                <div><div id="yiv7393495876gmail-m_7424619492073957442yiv1128969730"><div><div dir="ltr"><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">Try just using a java list.  As I understand it, that should work the same way.<br clear="none"></span></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">Since Java.util.List is abstract,  you need to choose a concrete class, such as ArrayList</span>. <br clear="none"></span></div><div><span style="font-family:monospace;"><br clear="none"></span></div><div><span style="font-family:monospace;">(let ((jlist (jss::new 'arraylist)))</span></div><div><span style="font-family:monospace;"></span></div><span style="font-family:monospace;">  (loop for el in '(1 2 3 4 5)<br clear="none">        do (#"add" jlist el))<br clear="none">  (print (jss::jlist-to-list jlist))<br clear="none"></span><div><span style="font-family:monospace;">  jlist)</span></div><div><span style="font-family:arial, sans-serif;"><br clear="none"></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">The print statement is to verify that we got what was expected, and to demonstrate jlist-to-list.</span><br clear="none"></span></div><div><span style="font-family:monospace;"><span style="font-family:arial, sans-serif;">Alan</span><br clear="none"></span></div></div><br clear="none"><div id="yiv7393495876gmail-m_7424619492073957442yiv1128969730yqt50833"><div><div dir="ltr">On Fri, Jul 24, 2020 at 10:21 PM Steven Nunez <<a rel="nofollow" shape="rect" ymailto="mailto:steve_nunez@yahoo.com" target="_blank" href="mailto:steve_nunez@yahoo.com">steve_nunez@yahoo.com</a>> wrote:<br clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
        <div dir="ltr"><div><div dir="ltr">I think what <a rel="nofollow" shape="rect" target="_blank" href="https://spark.apache.org/docs/latest/api/java/org/apache/spark/api/java/JavaSparkContext.html#parallelize-java.util.List-">parallelize </a>really
 needs is a java.util.list. Alessio mentioned some reasons why an 
automatic conversion is challenging; perhaps a restart is easier? I.e. 
search for a method of the given name that takes a java.util.list, and 
if you're giving it an abcl.cons, the restart asks if you want an 
automatic conversion.</div><div dir="ltr"><br clear="none"></div>Trying
 such a conversion manually, it seems I need a jlist-from-list, but this
 doesn't exist in the JAVA package.  How do I get a java.util.list from 
an abcl.cons ?</div><div><br clear="none"></div><div><br clear="none"></div></div><div><br clear="none"></div>
        
        </div><div id="yiv7393495876gmail-m_7424619492073957442yiv1128969730gmail-m_-3946531928573537175yahoo_quoted_5879194436">
            <div style="font-family:Helvetica, Arial, sans-serif;font-size:13px;color:rgb(38,40,42);">
                
                <div>
                    On Saturday, July 25, 2020, 5:20:30 AM GMT+8, Alan Ruttenberg <<a rel="nofollow" shape="rect" ymailto="mailto:alanruttenberg@gmail.com" target="_blank" href="mailto:alanruttenberg@gmail.com">alanruttenberg@gmail.com</a>> wrote:
                </div>
                <div><br clear="none"></div>
                <div><br clear="none"></div>
                <div><div id="yiv7393495876gmail-m_7424619492073957442yiv1128969730gmail-m_-3946531928573537175yiv1121038856"><div><div dir="ltr"><div>If you send a smallish example of the code that doesn't work, and a list of the dependencies, I can have a look. I've been dealing with some stuff recently that might make it easier to debug. <br clear="none"></div><div>You definitely can't use CopyToArray that way. You need to work with a java array</div><div>(jarray-from-list '(1 2 3 4 5))</div><div>Maybe:</div><div><div dir="ltr"><font face="lucida console, sans-serif"><span><span><font style="background-color:inherit;" face="courier new, courier, monaco, monospace, sans-serif"><span><span>(#"parallelize" *sc* (jarray-from-list '(1 2 3 4 5)))</span></span></font></span></span></font></div><div dir="ltr"><font face="lucida console, sans-serif"><span><span><font style="background-color:inherit;" face="courier new, courier, monaco, monospace, sans-serif"><span><span><br clear="none"></span></span></font></span></span></font></div><div><font face="lucida console, sans-serif"><span><span><font style="background-color:inherit;" face="courier new, courier, monaco, monospace, sans-serif"><span><span><span style="font-family:arial, sans-serif;"><font style="background-color:inherit;" size="2">Alan</font></span><br clear="none"></span></span></font></span></span></font></div></div></div><br clear="none"><div id="yiv7393495876gmail-m_7424619492073957442yiv1128969730gmail-m_-3946531928573537175yiv1121038856yqt47068"><div><div dir="ltr">On Thu, Jul 23, 2020 at 11:03 PM Steven Nunez <<a rel="nofollow" shape="rect" ymailto="mailto:steve_nunez@yahoo.com" target="_blank" href="mailto:steve_nunez@yahoo.com">steve_nunez@yahoo.com</a>> wrote:<br clear="none"></div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex;"><div><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div dir="ltr">OK, I'm on lines 4 and 5 of 'hello world' and ran into yet another brick wall. Trying to convert the following two lines into ABCL:</div><div dir="ltr"><font face="lucida console, sans-serif"><br clear="none"></font></div><div dir="ltr"><div><pre><font face="lucida console, sans-serif"><code><span>List</span><span><</span><span>Integer</span><span>></span> <span>data</span> <span>=</span> <span>Arrays</span><span>.</span><span>asList</span><span>(</span><span>1</span><span>,</span> <span>2</span><span>,</span> <span>3</span><span>,</span> <span>4</span><span>,</span> <span>5</span><span>);</span>
<span>JavaRDD</span><span><</span><span>Integer</span><span>></span> <span>distData</span> <span>=</span> <span>sc</span><span>.</span><span>parallelize</span><span>(</span><span>data</span><span>);</span></code></font></pre></div><div><br clear="none"></div><div dir="ltr">it looks like it should be easy. Heck, I can do that in one line:</div><div dir="ltr"><br clear="none"></div><div dir="ltr"><font face="courier new, courier, monaco, monospace, sans-serif"><span>(#"parallelize" *sc* '(1 2 3 4 5)) ; *sc* defined yesterday and known to be correct</span></font></div><div dir="ltr"><span><br clear="none"></span></div><div dir="ltr"><span>But no, it claims "no applicable method named parallelize found on JavaSparkContext" (but there is!). Reading through section 3.1.1 of the documentation, it appears that this is probably because '(1 2 3...) is a LispObject and not a Java object (why no automatic conversion?). Let's try to convert it:</span></div><div dir="ltr"><span><br clear="none"></span></div><div dir="ltr"><span></span><font face="courier new, courier, monaco, monospace, sans-serif"><span>(#"parallelize" *sc* (#"copytoArray" '(1 2 3 4 5)))</span></font></div><div dir="ltr"><font face="courier new, courier, monaco, monospace, sans-serif"><span><br clear="none"></span></font></div><div dir="ltr"><font face="courier new, courier, monaco, monospace, sans-serif"><span><span>No instance method named copytoArray found for type org.armedbear.lisp.Cons'</span></span></font></div><div dir="ltr"><font face="lucida console, sans-serif"><span><span><br clear="none"></span></span></font></div><div dir="ltr"><font face="lucida console, sans-serif"><span><span><font style="background-color:inherit;" face="Helvetica Neue, Helvetica, Arial, sans-serif">And the same with using an array, e.g. </font><font style="background-color:inherit;" face="courier new, courier, monaco, monospace, sans-serif"><span><span>(#"parallelize" *sc* (#"copytoArray" #(1 2 3 4 5)))</span></span></font></span></span></font></div><div dir="ltr"><span><span><span><span><br clear="none"></span></span></span></span></div><div dir="ltr"><span><span><span><span><b><span><font style="background-color:inherit;" face="lucida console, sans-serif"><span><span><font style="background-color:inherit;" face="Helvetica Neue, Helvetica, Arial, sans-serif"><i><font size="3">Sigh</font></i></font></span></span></font></span></b><br clear="none"></span></span></span></span></div><div dir="ltr"><span><span><span><span><br clear="none"></span></span></span></span></div><div dir="ltr"><span><span><span><span></span></span></span></span>It's been a week and my intention was to have a working prototype by now and present ABCL as a viable alternative to use in a project. I haven't got past line 5 in 'hello world'. This doesn't bode well.<br clear="none"></div><div dir="ltr"><br clear="none"></div><div dir="ltr">I've been reading about ABCL for years, and it's impressive. Full MOP, extensible sequences, nearly 100% ANSI compliance, and the ability to deploy on the JVM are major achievements. However, as a not-inexperienced Lisp programmer, I find the barrier to entry remarkably high and the documentation and examples sparse and insufficient to surmount the hurdles I encountered.<br clear="none"></div><div dir="ltr"><br clear="none"></div><div dir="ltr">Please take these comments in the way they are intended: constructive feedback from someone who is a fan of the project and would love to be able to use it. It's nearly impossible to get Lisp introduced into enterprise environments, and ABCL provides a wedge into those types of projects, ticking the boxes on deployment and ability to work with legacy Java code. Perhaps it makes more sense to someone approaching Lisp from the Java side, but coming from the Lisp side to Java, there's a high barrier to entry. I know that no volunteer wants to write documentation, but more and clearer docs are sorely needed here. This is probably not news, but sometimes it helps to be reminded of the obvious.<br clear="none"></div><div dir="ltr"><br clear="none"></div><div dir="ltr">I hate giving up, so this will be a personal background project in the hopes that at the next opportunity things will have improved to the point where we can consider introducing ABCL, so if anyone has any pointers, generally (though I think I would have found any docs or examples (lsw2) by now) and explaining this problem in particular, it would be greatly appreciated.</div><div dir="ltr"><br clear="none"></div><div dir="ltr">@easye, you mentioned your ember project. If you're going to continue with that, please message me. A Spark wrapper would be useful, serve as a good exemplar for using ABCL to wrap a large library and, with a companion tutorial, help others overcome the kind of obstacles I've encountered. I'd be happy to contribute.<br clear="none"></div><div dir="ltr"><br clear="none"></div></div></div></div></blockquote></div></div></div></div></div>
            </div>
        </div></div></blockquote></div></div></div></div></div>
            </div>
        </div></div></blockquote></div></div></div></div></div></div>
            </div>
        </div></body></html>