Problem with "-" in definterface method name

22 views
Skip to first unread message

Adrian Cuthbertson

unread,
Jun 1, 2010, 12:28:13 PM6/1/10
to clo...@googlegroups.com
Hi,

It seems definterface/deftype have a problem with "-" in the method name...

... Clojure 1.2.0-master-SNAPSHOT (today)

(definterface INm (^String get-nm []))
==> user.INm
(deftype Nm[nm] INm (^String get-nm [this] (str "Mr " nm)))
==> java.lang.IllegalArgumentException: Can't define method not in
interfaces: get_nm (NO_SOURCE_FILE:2)

(definterface INm (^String getnm []))
==> user.INm
(deftype Nm[nm] INm (^String getnm [this] (str "Mr " nm)))
==> user.Nm
(.getnm (Nm. "Smith"))
==> "Mr Smith"

Is that a bug or is there a usage rule I'm missing?

Thanks, Adrian.

Adrian Cuthbertson

unread,
Jun 1, 2010, 12:38:14 PM6/1/10
to Clojure
> Is that a bug or is there a usage rule I'm missing?

seems so - underscore in the definterface method works...

(definterface INm (^String get_nm []))
==> user.INm
(deftype Nm[nm] INm (^String get-nm [this] (str "Mr " nm)))
(.get-nm (Nm. "Smith"))
==> "Mr Smith"


Meikel Brandmeyer

unread,
Jun 1, 2010, 1:41:28 PM6/1/10
to clo...@googlegroups.com
Hi,

On Tue, Jun 01, 2010 at 09:38:14AM -0700, Adrian Cuthbertson wrote:

> > Is that a bug or is there a usage rule I'm missing?
> seems so - underscore in the definterface method works...

I would think get-nm is not a valid Java method name.

Sincerely
Meikel

Stuart Halloway

unread,
Jun 1, 2010, 1:41:54 PM6/1/10
to clo...@googlegroups.com
definterface makes an actual Java interface. Java does not allow "-".

Attempting this should probably fail with an error message.

Stu

> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clo...@googlegroups.com
> Note that posts from new members are moderated - please be patient with your first post.
> To unsubscribe from this group, send email to
> clojure+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

Reply all
Reply to author
Forward
0 new messages