From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104567 invoked by alias); 17 Sep 2017 15:38:18 -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 104556 invoked by uid 89); 17 Sep 2017 15:38:18 -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_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 17 Sep 2017 15:38:07 +0000 Received: by mail-wm0-f42.google.com with SMTP id g206so17043266wme.0 for ; Sun, 17 Sep 2017 08:38:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=vJ98ao/g1qQDq6JkI3vUSDJccuru9Xqm6yzS0ISX6iM=; b=KgNeEurpu6nFCzN+Xvn11ZhvVo2llYgWcCpTOdHeik+7TaxjapM3MxyK+uAGQz1aPi TiS2Ozm5ljzsWgKvuUo0NMX+rtUllKtSLpE3L0OUuI3BRdPI7aB8N03yL4b6ckDYsdtQ qvMykTbajXI0ZQm4MPratGLAUpBg188JrEquTkpDGfAPu7OoeYC8r2/mhwwq9HI7sujE ETLKv8e0KTW3Mt0+C6am+4kLs/oNqkb/+97bxeIu1iy7jw8ski7mw/YhPtqvOINcu6ZE ezxITuTcoLybIvD7h20jOvuYZEWrcSLI+D6eeZapvZAIHSVqBq1unT8SbAj1F4tmhkuR 1ktw== X-Gm-Message-State: AHPjjUi8zyuDpzjnneI8yxu4J6YzKpmGZiGasoRBEvQ/arHZ+QDfENBg PLlAVDAizxERbq9wPL+R0cpkYMTWAQn+8RPKDpJEZCuK X-Google-Smtp-Source: AOwi7QCHgCZy6dmXCslvRdVhBAr9aHwPa9n+gMEr7dcCiEUIKQVP6p6h9kHJAeO1cK0FAbu7RiFXfwIF2L7kPzgZui8= X-Received: by 10.28.199.13 with SMTP id x13mr3454494wmf.124.1505662685403; Sun, 17 Sep 2017 08:38:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.200.2 with HTTP; Sun, 17 Sep 2017 08:38:04 -0700 (PDT) In-Reply-To: References: From: Sonny To Date: Sun, 17 Sep 2017 15:38:00 -0000 Message-ID: Subject: Re: using lambda to implement one method interface To: Kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00048.txt.bz2 this works (let ((handler (android.os.Handler (android.os.Looper:getMainLooper))) ) (handler:post (lambda () (android.util.Log:i "scm" "run me"))) ) this is non-intuitive. why doesn't it work if i bind the lambda to a symbol? seems like a bug to me On Sun, Sep 17, 2017 at 8:32 AM, Sonny To wrote: > follwing docs at https://www.gnu.org/software/kawa/Anonymous-classes.html > > (let ((handler (android.os.Handler (android.os.Looper:getMainLooper))) > (runnable (lambda () > (android.util.Log:i "scm" "run me")))) > (handler:post runnable) > ) > > that doesn't seem to work. Do I need to give type hints to be able to do this? > > I'm getting this error: > > #|.....44|# #|.....45|# #|.....46|# #|.....47|# /dev/stdin:46:17: > warning - type function is incompatible with required type > java.lang.Runnable > java.lang.ClassCastException: don't know how to coerce > gnu.expr.LambdaExp$Closure to java.lang.Runnable > at gnu.bytecode.ObjectType.coerceFromObject(ObjectType.java:180) > at gnu.kawa.functions.Convert.apply2(Convert.java:38) > at gnu.mapping.Procedure2.applyToObject(Procedure2.java:62) > at java.lang.reflect.Method.invoke(Native Method) > at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726) > at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75) > at java.lang.reflect.Method.invoke(Native Method) > at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726) > at gnu.mapping.CallContext.runUntilDone(CallContext.java:586) > at gnu.mapping.CallContext.getFromContext(CallContext.java:616) > at gnu.expr.Expression.eval(Expression.java:52) > at gnu.expr.ApplyExp.apply(ApplyExp.java:161) > at gnu.expr.LetExp.apply(LetExp.java:72) > at gnu.expr.ModuleExp.evalModule2(ModuleExp.java:281) > at gnu.expr.ModuleExp.evalModule(ModuleExp.java:211) > at kawa.Shell.run(Shell.java:283) > at kawa.Shell.run(Shell.java:196) > at kawa.Shell.run(Shell.java:183) > at kawa.TelnetRepl.apply0(TelnetRepl.java:25) > at gnu.mapping.RunnableClosure.run(RunnableClosure.java:75) > at java.lang.Thread.run(Thread.java:764)