Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 886707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:06:47+00:00 2026-05-15T13:06:47+00:00

I’m trying to embed a swank-clojure repl into my application for the purpose of

  • 0

I’m trying to embed a swank-clojure repl into my application for the purpose of connecting while the app is running to muck around with things. However, I’m having trouble figuring out how to access the enclosing environment after starting the repl.

Embedding the swank-clojure REPL is easy enough:

(ns mytest
  (:use [swank.swank :exclude [-main]])
  (:gen-class))

(defn -main [& args]
  (let [x 123]
    (swank.swank/start-repl)))

Run the program.. then over in emacs:

M-x slime-connect 

That works fine and I am connected. Now, what I hoped was that this would work:

(println x)
;; 123 (what I was hoping for)
;; Unable to resolve symbol: x in this context (cruel reality)

So that doesn’t work as a way to pass the current environment to the embedded REPL.

Is there any way for the embedded REPL to interact with my running program?

If not, what reasons are there to embed a REPL?

If it makes any difference, I am trying to run this as a JAR.

This thread seems related, but I wasn’t able to get anywhere from it:

Embedding swank-clojure in java program

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T13:06:48+00:00Added an answer on May 15, 2026 at 1:06 pm

    let-bound locals are lexically scoped, thus swank.swank/start-repl won’t be affected by a let form wrapped around the call to it. However, the running REPL will be able to require / use any Clojure namespaces on your application’s classpath (or use in-ns to switch the REPL’s namespace to one of those) and to import any Java classes on the classpath, allowing you to do a number of very useful things, such as redefining functions, examining and changing the contents of any Refs / Atoms / other things of interest held in Vars, calling functions / Java methods etc.

    Note that you probably shouldn’t (:use swank.swank) in your ns form; (:require swank.swank) instead. The difference is that the former pulls in all swank.swank‘s public Vars into your namespace, while the latter doesn’t (use = require + refer, see (doc use) etc. for details). You seem to use namespace-qualified symbols to access Swank’s Vars, so you might not even have to change the rest of your code, and require avoids cluttering up your namespace. Alternatively, (:use [swank.swank :only [start-repl]]); this pulls in just the start-repl Var, which you could then use directly, without the swank.swank/ bit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.