From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 37510 invoked by alias); 18 Sep 2017 12:34:45 -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 36254 invoked by uid 89); 18 Sep 2017 12:34:44 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Sep 2017 12:34:43 +0000 Received: by mail-wr0-f175.google.com with SMTP id g29so333796wrg.11 for ; Mon, 18 Sep 2017 05:34:42 -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:cc; bh=Uz8X3MRuWDaPLinFPRgUyvF24RS8iaFqfmIOLRGvHIM=; b=Ksc4jfBDCUDMH5rvq9O1zGn+TrKPX2fHCffyWiU4vcH7ka28mOLLHE/bAtvdlH6GaU r9SKTgA6T8TAd9n4hevzLfUphN5pY4yNAehAnOV0+8VfU8RgJHoJfttDO2PX9OXpz5+V Q+RC0VlvpFlGun8aGETVwNjZ5JIjuoiEHizUK3bDmvDTjo96lJFQh2F48EAh8fHN/hcZ gdrWUJYVQbPjkROKb7pQxpxZPtjMAWbVXPprc/ONMw+Kr5x4hkVAKNxc4LUsVM/vzC+a b0qMsFnCcwP3GLUNc0PO3rStRFes0TOjU9u5abNI3jmTocGqHcORn+htwTfneqAvtk1k OGPw== X-Gm-Message-State: AHPjjUgYuM6QdhXOsaXFwX7uTMKOFn597Fra3EOwwlA5v5LvEwt30nF0 ejHNODvrZDAOVwldS9Vav0Q/XHdRrhwSSY0ssRaKAQ== X-Google-Smtp-Source: ADKCNb6X5wA7N2uN7DM0aKqcLasgbXROLQj0iFeaPuXRaFZKhQpLbmhhGj+frCk67dlSs6vvA9TpnUSmMaMRuzcD8EM= X-Received: by 10.223.152.117 with SMTP id v108mr30065546wrb.76.1505738080707; Mon, 18 Sep 2017 05:34:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.200.2 with HTTP; Mon, 18 Sep 2017 05:34:40 -0700 (PDT) In-Reply-To: References: From: Sonny To Date: Mon, 18 Sep 2017 12:34:00 -0000 Message-ID: Subject: Re: scoping rules To: Per Bothner Cc: Kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00066.txt.bz2 sorry the problem with this example is due to my ignorance on scheme's let. I'm use to clojure's let let* is what I should have used On Mon, Sep 18, 2017 at 11:29 AM, Sonny To wrote: > I was able to reproduce strange behavior with symbol scope on the jvm: > > (define (run-in-ui-thread fn) > (let ((t :: java.lang.Thread (java.lang.Thread (object (java.lang.Runnable) > ((run)::void > (fn)))))) > (t:start))) > > (run-in-ui-thread (lambda () > (let ( (a 1) > (b 2) > (c (+ a b))) > (display c)))) > > here's the stacktrace > > /dev/stdin:37:15: warning - no declaration seen for b > #|kawa:39|# Exception in thread "Thread-4" /dev/stdin:37:13: unbound location: a > at gnu.mapping.DynamicLocation.get(DynamicLocation.java:36) > at atInteractiveLevel$Mn5.lambda1(stdin:37) > at atInteractiveLevel$Mn5.lambda1$check(stdin:34) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:497) > at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726) > at gnu.mapping.Procedure.applyToConsumerDefault(Procedure.java:75) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:497) > at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726) > at gnu.kawa.functions.ApplyToArgs.applyToConsumerA2A(ApplyToArgs.java:132) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:497) > at gnu.mapping.CallContext$ReflectMethodHandle.invokeExact(CallContext.java:726) > at gnu.mapping.CallContext.runUntilDone(CallContext.java:586) > at gnu.mapping.CallContext.runUntilValue(CallContext.java:669) > at gnu.mapping.Procedure.apply1(Procedure.java:148) > at atInteractiveLevel$Mn1$0.run(stdin:5) > at java.lang.Thread.run(Thread.java:745) > > > This however works: > > (run-in-ui-thread (lambda () > (let ( (a 1) > (b 2)) > (display (+ a b))))) > > > > On Sun, Sep 17, 2017 at 9:49 PM, Sonny To wrote: >> ok let me see if i can reproduce this outside of android >> >> On Sun, Sep 17, 2017 at 10:45 AM, Per Bothner wrote: >>> On 09/17/2017 09:51 AM, Sonny To wrote: >>>> >>>> sorry for the newb question but i find this behavior odd >>>> >>>> (let ((handler (android.os.Handler (android.os.Looper:getMainLooper))) >>>> (c context)) >>>> (handler:post (lambda () >>>> (let ((t (android.widget.Toast:makeText (as >>>> android.app.Application c) "foobar" 1000))) >>>> (t:show)) >>>> ))) >>>> >>>> To get this example to work I had to bind c context in the top level let >>>> in the second let, I have to use c instead of context directly. >>>> (android.widget.Toast:makeText (as android.app.Application context) >>>> will complain >>>> >>>> /dev/stdin:45:93: unbound location: context >>>> >>>> it could not see the context binding. >>>> Should it not look in the environment? context is definitely in the >>>> environment because the c binding works >>> >>> >>> That does sound like a bug. Probably the interaction of dynamic >>> (environment) name-lookup >>> combined with the use of the anonymous class. >>> >>> If you can create a simple non-Android test-case I'll take a look. >>> >>> It is recommended to include the line: >>> >>> (define-variable context) >>> >>> as that tells the compiler to look for 'context' in the dynamic environment, >>> and avoids warnings when using --warn-undefined-variable. >>> -- >>> --Per Bothner >>> per@bothner.com http://per.bothner.com/