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 6731595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:32:53+00:00 2026-05-26T10:32:53+00:00

I have a Clojure proxy statement that was getting large and messy, so I

  • 0

I have a Clojure proxy statement that was getting large and messy, so I decided to try factoring the code of the beginDrag method redefinition out of the proxy statement, like this:

(defn enhanced-start-drag
  ""
  [pie]
  (let [pobj   (. pie getPickedNode)
    pobj-coll (seq (.. pie getInputManager
               getKeyboardFocus getSelection))]
    (println pobj)
    (println pobj-coll)
    (println "----------")
    (proxy-super startDrag pie)))  ; THIS IS LINE 94 (SEE ERROR MSG)



(defn custom-selection-event-handler [marqueeParent selectableParent]
  (proxy [PSelectionEventHandler]  [marqueeParent selectableParent]
    (decorateSelectedNode [node]
              (let [stroke-color (Color/red)]
                (.setStrokePaint node stroke-color)))
    (undecorateSelectedNode [node]
                (let [stroke-color (Color/black)]
                  (.setStrokePaint node stroke-color)))
    (startDrag [pie]    ; pie is a PInputEvent
           (enhanced-start-drag pie))
    (endStandardSelection [pie]     ; pie is a PInputEvent
              (let [pobj   (.getPickedNode pie)
                slip   (. pobj getAttribute "slip")
                ]
                (swap! *last-slip-clicked*
                   (fn [x] slip))))))

I get the following compile error:

cd /Users/gw/tech/clojurestuff/cljprojects/infwb/src/infwb/
1 compiler notes:

Unknown location:
  error: java.lang.Exception: Unable to resolve symbol: this in this context

core.clj:94:5:
  error: java.lang.Exception: Unable to resolve symbol: this in this context 
    (core.clj:94)

Compilation failed.

As soon as I restore the body of enhanced-start-drag into the body of the proxy statement, everything works.

My question: Is there a way to move the messy details out to a separate function to improve the readability of my code?

Thanks for all your ideas and solutions.


UPDATE, 10/27/11: See the comments below. Arthur Ulfeldt was sharp in pointing out that the issue is captured references, and Dave Ray is also correct in saying that all you have to do is add this as a parameter to enhanced-start-drag and then proxy-super will work correctly. When I made the following two changes (without any changes to the body of enhanced-start-drag), my code was working again:

  (defn enhanced-start-drag
    ""
    [pie this]

and

  (startDrag [pie]  ; IN THE PROXY STMT IN custom-selection-event-handler
   (enhanced-start-drag pie this))

BTW, my project uses Dave Ray’s seesaw project to get a Java Swing UI. seesaw is awesome, as are its docstrings and sample code (which are much better than most commercial software). I highly recommend it! And thank you, Dave!

  • 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-26T10:32:53+00:00Added an answer on May 26, 2026 at 10:32 am

    You have been bitten by symbol capture. In this case it is intentaional though you need to stay aware of it. From the doc for proxy-super

    Use to call a superclass method in the body of a proxy method. 
    Note, expansion captures 'this`
    

    proxy is creating a class that calls a function, when the call gets into enhanced-start-drag the value of this is not where proxy-super expects

    you may needs to pass this as another argument into enhanced-start-drag and then call (. saved-this ...) instead of using proxy-super.


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

Sidebar

Related Questions

I have some Clojure code that seems maddeningly simple and yet is throwing an
I have some Clojure code that is simulating and then processing numerical data. The
I have the following Clojure code and I'm not sure why it's not working:
I have a clojure project that uses the slick 2d game engine that I
I have a complex Clojure data structure that I would like to serialize -
I have Clojure function that takes a sequence of numbers chops it into the
I have a group of numeric functions in Clojure that I want to validate
We are running nginx as a reverse proxy that forwards requests to a Clojure
I have a Clojure map that may contain values that are nil and I'm
In clojure I have lines like this that define default values: (def *http-port* 8080)

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.