• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

First function in tutorial fails: IllegalStateException - Attempting to call unbound function

 
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am going through the Try clojure tutorial.
It has a hello world function -

When i hit above command on the

clojure>

prompt , I get below-


#'sandbox24027/square

which looks like a success message.
But when I call it-

I get below exception -

java.lang.IllegalStateException- Attempting to call unbound function - 'sandbox24027/square


Looks like it can read the compiled function but can not call it. Any idea?

Same has happened with other functions I tried to create.
 
author
Posts: 27
Clojure
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're calling the square function slightly wrong (you're passing a vector containing a number, and not a number; watch the brackets), but I actually get a different error than you (java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Number).

It sounds like your TryClj session might be hosed, or the site was having issues at the time? Maybe try again.

FWIW, here's a session copy/pasted from TryClj:



--
(coauthor of Clojure Programming from O'Reilly; creator of Clojure Atlas)
 
Aniruddh Joshi
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get the same error even after removing the square brackets -


Clojure> (def square (fn [x] (* x x)))
#'sandbox24027/square
Clojure> (square 45)
java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox24027/square
Clojure> (square 3)
java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox24027/square



let me try a new session.. maybe I've tried craeting the same function multiple times.
 
Aniruddh Joshi
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
With a new browser session I am on the same page as you
Probably my sandbox went stale by trying multiple things on the same function.
Thanks!
 
Aniruddh Joshi
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Reproduced the problem, check below-


Clojure> (defn fuzz [x] ( * 1.23 ( / x 7 )) )
#'sandbox24027/fuzz
Clojure> fuzz 8
#<sandbox24027$fuzz sandbox24027$fuzz@3a790aaa>
Clojure> (fuzz 8)
java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox24027/fuzz



Which means if I call it incorrectly once, it goes for a toss?

What does

Clojure> fuzz 8

do ?
 
Rancher
Posts: 369
22
Mac OS X Monad Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aniruddh Joshi wrote:What does

Clojure> fuzz 8

do ?


It evaluates fuzz then it evaluates 8. The former will either resolve to a symbol and it's internal name will be displayed (that sandbox...$fuzz... string you saw) or an exception if it is unknown. The latter will resolve to the value 8 which will be displayed.
 
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aniruddh Joshi wrote:Reproduced the problem, check below-


Clojure> (defn fuzz [x] ( * 1.23 ( / x 7 )) )
#'sandbox24027/fuzz
Clojure> fuzz 8
#<sandbox24027$fuzz sandbox24027$fuzz@3a790aaa>
Clojure> (fuzz 8)
java.lang.IllegalStateException: Attempting to call unbound fn: #'sandbox24027/fuzz



Which means if I call it incorrectly once, it goes for a toss?

What does

Clojure> fuzz 8

do ?



I didnt get any exceptions. See below:-

 
Aniruddh Joshi
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Palak- try reversing the order of your last 2 commands.
 
Palak Mathur
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Aniruddh Joshi wrote:@Palak- try reversing the order of your last 2 commands.



It worked:-

 
Palak Mathur
Ranch Hand
Posts: 343
Mac OS X Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What exactly do you think the issue might be? I didn't receive any error.
 
Aniruddh Joshi
Ranch Hand
Posts: 275
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe like Chas said, something wrong with tryclj.
Will try it again when I get some time.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic