This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: scoping rules
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/