From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28036 invoked by alias); 15 Sep 2017 13:48:05 -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 26245 invoked by uid 89); 15 Sep 2017 13:48:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 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-wm0-f49.google.com Received: from mail-wm0-f49.google.com (HELO mail-wm0-f49.google.com) (74.125.82.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 13:48:01 +0000 Received: by mail-wm0-f49.google.com with SMTP id i189so8503702wmf.1 for ; Fri, 15 Sep 2017 06:48:01 -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=r7cnwgrMoDrf1jTx97J2kQQXIBWp1kiVqWg91cfn5v0=; b=ZEMpmhZG+W/jUNNO9xHbZltB3eyG3B31qyj6ugh5C3ZC3tJXobnMV7PK6Dn5pIBI5P yGaWS9uNEAtQfWbetXnXOab6BuRPWRe0XU7qNs5udZV7ZOsQtn18btFhBjPmSP2wbW7x mrvZa0eK82GlvVDfLQ+hEra/Z4zGcWLedUTO99N875UW9NL5vp3DHmsW0ZJs+9I0uujh 6R+JB80X2Os8i9COHXaQYEY73Dntt0l8DMmH2p+KQiy+XkbG+TN3t2ueC1h7jFDS1gSE 2yT5IQrdzXvkzbbomomnLai/A7lp383weF6sM71UDW0+eLPG68ha5msyA23IisFa7Gup DpnQ== X-Gm-Message-State: AHPjjUg09E9QbBn5QGnxfzzq0fIkrJdcMiXLbgfl0P+XWmxt91VY8TS8 9XpfKQw7nPdw7zUFROnzVePtR5vkkLOuBfGXUL1zDoAG X-Google-Smtp-Source: AOwi7QBn70KPyHKS9vJzi8Er2Jglh1IcyEKz7IYnmtuuV/aXkMcZD/6VLwcgH3w/OH7nF6R0ja2dF1ie1tlLOfSvKbM= X-Received: by 10.28.199.13 with SMTP id x13mr2551314wmf.124.1505483279148; Fri, 15 Sep 2017 06:47:59 -0700 (PDT) MIME-Version: 1.0 Received: by 10.223.200.2 with HTTP; Fri, 15 Sep 2017 06:47:58 -0700 (PDT) In-Reply-To: References: <7ebc09b0-2243-a1c0-4da2-d4f0fb73827e@bothner.com> From: Sonny To Date: Fri, 15 Sep 2017 13:48:00 -0000 Message-ID: Subject: Re: putting symbols into Environment To: Per Bothner , Kawa mailing list Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00043.txt.bz2 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 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 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/