From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17746 invoked by alias); 1 Mar 2014 22:30:35 -0000 Mailing-List: contact kawa-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: kawa-owner@sourceware.org Received: (qmail 17736 invoked by uid 89); 1 Mar 2014 22:30:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ve0-f181.google.com Received: from mail-ve0-f181.google.com (HELO mail-ve0-f181.google.com) (209.85.128.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 01 Mar 2014 22:30:33 +0000 Received: by mail-ve0-f181.google.com with SMTP id oy12so163388veb.40 for ; Sat, 01 Mar 2014 14:30:31 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.221.26.10 with SMTP id rk10mr9750464vcb.0.1393713031467; Sat, 01 Mar 2014 14:30:31 -0800 (PST) Received: by 10.58.122.69 with HTTP; Sat, 1 Mar 2014 14:30:31 -0800 (PST) In-Reply-To: References: Date: Sat, 01 Mar 2014 22:30:00 -0000 Message-ID: Subject: Re: Questions regarding modules From: Marius Kjeldahl To: kawa@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2014-q1/txt/msg00082.txt.bz2 I did figure out that (require "HelloKawa.scm") also works, but I still do not understand why the short form (HelloKawa:hello) works, but not (net.kjeldahl.kawatest.app.HelloKawa:hello) which is the full/proper name for that module (at least that's what I'm trying). Thanks, Marius K. On Sat, Mar 1, 2014 at 4:52 PM, Marius Kjeldahl wrote: > I've read and re-read the module explanations from Per many times, but > I still run into trouble, so I will ask here. My testing is done on > Android, using gradle. If you do not know gradle, what you might need > to know is that a project (by default) is laid out in a certain way. > For instance for a kawa source file for the class > net.kjeldahl.kawa.MyClass will exist in > src/main/kawa/net/kjeldahl/kawa/MyClass.scm . Similarily, the output > of the class files will go into the path > build/classes/debug/net/kjeldahl/kawa/MyClass.class . To the best of > my abilities I've also verified that the class files get put where > they are supposed to be and that the stuff in them is correct (proper > class names, using javap to check the contents). > > Anyway, I have my Android activity defined in it's own > KawaActivity.scm file more or less like follows: > > (module-name net.kjeldahl.kawatest.app.KawaActivity) > ... > (require net.kjeldahl.kawatest.app.HelloKawa "HelloKawa.scm") > > (define-simple-class KawaActivity (Activity) > ((onCreate (savedInstanceState::Bundle)) (@Override) > (invoke-special Activity (this) 'onCreate savedInstanceState) > (define tv::TextView (TextView (this) text: "Kawa hello.")) > (define my-view::View (LinearLayout (this) > orientation: LinearLayout:VERTICAL > view: tv)) > ((this):setContentView my-view) > (define str (string-append "Retval: " (HelloKawa:hello))) > (tv:setText str) > )) > > The HelloKawa.scm source file is located in the same "namespace" and > directory as the file above, and simply contains: > > (module-name net.kjeldahl.kawatest.app.HelloKawa) > > (define-simple-class HelloKawa () > ((hello) allocation: 'static > "Hello from HelloKawa!")) > > ;; (define (hello) > ;; "Hello from Kawa!") > > The code shown above works just fine. What I am having trouble with is > figuring out why certain things are needed and not. > > Question 1 - The line that does require HelloKawa; Unless I list the > filename "HelloKawa.scm" as the second parameter, I will get a kawa > compiler error; invalid specifier for 'require'. I have no idea why. > I've experienced with setting the working dir prior to calling the > kawa compiler, but it does not seem to matter much. It looks like kawa > has it's own idea about the proper path for start searching for the > source file for the module. > > Question 2 - When invoking (HelloKawa:hello), how come kawa knows > about my HelloKawa class without the full class name? I haven't done > any define-alias on it, so it's a bit unexpected. > > Question 3 - The file defining HelloKawa uses define-simple-class, but > I've also tried it with a straight up define instead (you'll see that > commented out in the source file above). If I do that, I get two > errors from kawa; no known slot hello in java.lang.Object, and no > declaration seen for HelloKawa. Based on what I've read, this second > method of defining a module should work as long as we stay within the > kawa domain, but I may have interpreted that wrong. > > And just to reiterate; I realize there are better ways to write this > kind of code on Android. The trouble is there is a lot more code out > there than Android, and I need to get comfortable with the mappings > before I dare to try and do real stuff with this. If I'm still > struggling at these basic things I can assure you when/if others try > to follow they will have similar issues. So I'm hoping to have some > answers ready! > > Thanks, > > Marius K.