From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32568 invoked by alias); 3 Mar 2014 20:50:56 -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 32492 invoked by uid 89); 3 Mar 2014 20:50:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-ob0-f182.google.com Received: from mail-ob0-f182.google.com (HELO mail-ob0-f182.google.com) (209.85.214.182) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 03 Mar 2014 20:50:52 +0000 Received: by mail-ob0-f182.google.com with SMTP id uz6so7392271obc.13 for ; Mon, 03 Mar 2014 12:50:51 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.182.33.6 with SMTP id n6mr4012524obi.48.1393879851122; Mon, 03 Mar 2014 12:50:51 -0800 (PST) Received: by 10.76.88.103 with HTTP; Mon, 3 Mar 2014 12:50:51 -0800 (PST) In-Reply-To: <5314E655.7090809@bothner.com> References: <531267B8.6040407@bothner.com> <53144610.9040207@bothner.com> <5314E655.7090809@bothner.com> Date: Mon, 03 Mar 2014 20:50:00 -0000 Message-ID: Subject: Re: Questions regarding modules From: Marius Kjeldahl To: Per Bothner Cc: kawa@sourceware.org Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2014-q1/txt/msg00090.txt.bz2 As I've written, plain "(hello)" works when I include the module with (require "HelloKawa.scm"). For good reasons I need to control where the exported symbols appear when requiring the module, not when defining the individual methods, which is why simply importing all the defines doesn't cut it. That's why I'm trying to put it into a class (I really want a namespace, but who cares). Which I've managed to do when using define-class as explained already. However, the docs you've written under the section "How a module becomes a class" states that using module-name is an alternative to define-class, and THIS is what I am struggling to get working. Without resorting to using define-class in HelloKawa.scm, I am not able to use (net.kjeldahl.kawatest.app.HelloKawa:hello) at all. If possible, could you show me how I can define the "class" in HelloKawa.scm with module-name and defining the hello method in it so that it would be callable with the full name net.kjeldahl.kawatest.app.HelloKawa:hello from KawaActivity? I would be perfectly happy to be told that define-class IS what I need to use, but based on how I understand the docs, kawa offers a "less javalike" method of defining "javalike" classes, and that is what I'm trying to figure out. Thanks, Marius K. On Mon, Mar 3, 2014 at 9:30 PM, Per Bothner wrote: > On 03/03/2014 01:23 AM, Marius Kjeldahl wrote: >> >> If it's a bug than certainly explains my struggles. >> >> I can confirm that the import statement does not trigger the error >> that the similar require statement does. However I am still unable to >> access the "hello" function from KawaHello (when using the >> module-name/define pattern) using net.kjeldahl.kawatest.app.KawaHello. >> The same "no known slot hello in java.lang.Object" warning gets >> triggered. > > > Replace: > (HelloKawa:hello) > by plain: > (hello) > or: > (net.kjeldahl.kawatest.app.HelloKawa:hello) > > Remember what I wrote March 1: > > > When you (require MODULE) what happens is that all the public (exported) > names in MODULE are added to the current lexical scope. > > If you write: > > (module-name net.kjeldahl.kawatest.app.HelloKawa) > > (define (hello) > "Hello from Kawa!") > > then HelloKawa is *not* a public exported name in the module, > so it is *not* in scope in KawaActivity (or in HelloKawa). > > Kawa's default binding mechanism does add bindings for all > fully-qualified class names that exist in the classpath. > The is why you can write things like (java.util.ArrayList). > The binding is a default (fall-back), so it only triggers only > if there is no binding in the lexical scope. > > However, HelloKawa is not a fully-qualified class name. For that > you have to write: > (net.kjeldahl.kawatest.app.HelloKawa:hello) > > Best is to write plain: > (hello) > > -- > --Per Bothner > per@bothner.com http://per.bothner.com/