This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: putting symbols into Environment


oddly the fix is to first put into the environment before creating the repl

val env = Environment.getCurrent()
env.put(Symbol.valueOf("context"), applicationContext)
TelnetRepl.serve(lang, client)

the symbol "context" is now available in the repl

On Fri, Sep 15, 2017 at 4:48 AM, Sonny To <son.c.to@gmail.com> wrote:
> Thanks Per. I was looking for a Symbol.makeIntern but didnt find one
> and used Symbol.makeUninterned. I was not expecting a Symbol.valueOf
> to make an interned symbol. perhaps either rename or add an alias
> Symbol.makeIntern?
>
> In anycase, using Symbol.valueOf still does not make the "context"
> symbol available in my repl
>
> sto@obi:~$ telnet localhost 9999
> Trying 127.0.0.1...
> Connected to localhost.
> Escape character is '^]'.
> #|kawa:1|# context
> /dev/stdin:1:1: unbound location: context
> at gnu.expr.ReferenceExp.apply(ReferenceExp.java:163)
> 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)
>
> any other ideas? I suspect its because I have the wrong Environment
>
> On Wed, Sep 13, 2017 at 5:28 PM, Per Bothner <per@bothner.com> wrote:
>> On 09/13/2017 05:05 PM, Sonny To wrote:
>>>
>>> I'm trying to use the TelnetRepl in an android Service but cannot
>>> figure out how to put bindings into the environment
>>
>>
>>>                      env.put(Symbol.makeUninterned("context", null),
>>> applicationContext)
>>
>>
>>> I can telnet to it but the "context" symbol is not available
>>>
>>> #|kawa:4|# context
>>> /dev/stdin:4:1: unbound location: context
>>
>>
>> That would be expected if you use Symbol.makeUninterned.
>> An uninterned symbol is a unique object that you can *not*
>> "lookup".  For example (string->symbol "context") is the
>> same as 'symbol - but (Symbol:makeUninterned "context") is a completely
>> different object.
>>
>> Instead, try Symbol.valueOf("context").
>>
>>> Do I have the wrong environment? if so how to get the correct environment?
>>
>>
>> There might be other problems, but fix the above-mentioned problem first.
>> --
>>         --Per Bothner
>> per@bothner.com   http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]