This page is no longer maintained — Please continue to the home page at www.scala-lang.org

naming conflict on clojure method

1 reply
Josh Stratton
Joined: 2009-04-23,
User offline. Last seen 42 years 45 weeks ago.

I'm playing around with clojure in my project and just noticed the
.var function throws an error being that it's a keyword in scala. I'm
not sure how to handle this as this is an external library outside the
realm of my code. I guess I could always put this part in java, but I
was wondering if anyone else has hit similar problems with better
solutions.

val editorFn = RT.var("user", "foo")

[error] /home/stratton/josh_projects/sunshine-client/src/main/scala/sunshine.scala:171:
identifier expected but 'var' found.
[error] val editorFn = RT.var("user", "get-ruby-editor")

Ken Scambler
Joined: 2009-11-07,
User offline. Last seen 42 years 45 weeks ago.
Re: naming conflict on clojure method
You can have identifiers the same as keywords by quoting it within backticks, like
 
val editorFn = RT.`var`("user", "foo")

Ken

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland