Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Confusing compiler error in defrecord and deftype.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Travis Hoffman  
View profile  
 More options Jul 20 2010, 3:00 pm
From: Travis Hoffman <travis.a.hoff...@gmail.com>
Date: Tue, 20 Jul 2010 12:00:07 -0700 (PDT)
Local: Tues, Jul 20 2010 3:00 pm
Subject: Confusing compiler error in defrecord and deftype.
Hello, I've come across the following compiler error in defrecord and
deftype:

java.lang.RuntimeException: java.lang.ClassCastException:
clojure.lang.PersistentList cannot be cast to clojure.lang.Symbol
(test.clj:0)

To generate the error, evaluate the following code:

(ns test)

(defrecord TestRecord [afield bfield cfield]
  (printc [_] (println cfield)))

(deftype TestType [afield bfield cfield]
  (printc [_] (println cfield)))

The error I believe I should be getting is something like this:

java.lang.IllegalArgumentException: Can't define method not in
interfaces: printc (test.clj:8)

Which can be generated with the following code:

(ns test)

(defprotocol TestProtocol
  ""
  (printa [testtype] "")
  (printb [testtype] ""))

(defrecord TestRecord [afield bfield cfield]
  TestProtocol
    (printa [_] (println afield))
    (printb [_] (println bfield))
    (printc [_] (println cfield)))

(deftype TestType [afield bfield cfield]
  TestProtocol
    (printa [_] (println afield))
    (printb [_] (println bfield))
    (printc [_] (println cfield)))

I haven't found, on Assembla, to submit a ticket, otherwise I would
have done so. :-)

Cheers,
Travis


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stuart Halloway  
View profile  
 More options Jul 20 2010, 3:58 pm
From: Stuart Halloway <stuart.hallo...@gmail.com>
Date: Tue, 20 Jul 2010 15:58:32 -0400
Local: Tues, Jul 20 2010 3:58 pm
Subject: Re: Confusing compiler error in defrecord and deftype.
Hi Travis,

As you noticed, there is no error handling for the case where you pass a bad spec to defrecord. In your example, the spec has method bodies but no protocol-or-interface-or-Object.

I have created a ticket for this at https://www.assembla.com/spaces/clojure/tickets/405-better-error-mess....

The ticket comment includes instructions for how and where to patch this. If anyone has been frustrated by Clojure's error messages and is looking for an easy way to contribute, have at it. :-)

Stu


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Baishampayan Ghose  
View profile  
 More options Jul 22 2010, 7:41 am
From: Baishampayan Ghose <b.gh...@ocricket.com>
Date: Thu, 22 Jul 2010 17:11:51 +0530
Local: Thurs, Jul 22 2010 7:41 am
Subject: Re: Confusing compiler error in defrecord and deftype.

Stuart Halloway wrote:
> I have created a ticket for this at https://www.assembla.com/spaces/clojure/tickets/405-better-error-mess....

> The ticket comment includes instructions for how and where to patch this. If anyone has been frustrated by Clojure's error messages and is looking for an easy way to contribute, have at it. :-)

Do I need to have my CA on file before I can contribute? I have them
signed and ready to ship anyway...

Regards,
BG

--
Baishampayan Ghose <b.gh...@ocricket.com>
oCricket.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »