Details
-
Type:
Enhancement
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Declined
-
Affects Version/s: Release 1.4
-
Fix Version/s: Release 1.5
-
Component/s: None
-
Labels:
-
Patch:Code
-
Approval:Not Approved
Description
The compiler accepts this:
(deftype foo []
clojure.lang.IFn
(invoke [this & xs]))
However calling ((foo.) :bar) will throw an AbstractMethodError. Wouldn't some checking be desirable?
Attachments
Activity
Tassilo Horn
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Attachment | 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch [ 11376 ] |
Tassilo Horn
made changes -
| Labels | patch |
Tassilo Horn
made changes -
| Attachment | 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch [ 11377 ] |
Tassilo Horn
made changes -
| Attachment |
0001- |
Tassilo Horn
made changes -
| Attachment | 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch [ 11380 ] |
Tassilo Horn
made changes -
| Attachment |
0001- |
Rich Hickey
made changes -
| Patch | Code [ 10001 ] | |
| Approval | Vetted [ 10003 ] | |
| Fix Version/s | Release 1.5 [ 10150 ] |
Aaron Bedra
made changes -
| Approval | Vetted [ 10003 ] | Incomplete [ 10006 ] |
Tassilo Horn
made changes -
| Attachment | 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch [ 11462 ] |
Tassilo Horn
made changes -
| Attachment |
0001- |
Tassilo Horn
made changes -
| Attachment | 0001-CLJ-1024-Check-for-invalid-varags-destrucuring-uses.patch [ 11463 ] |
Tassilo Horn
made changes -
| Attachment |
0001- |
Stuart Halloway
made changes -
| Approval | Incomplete [ 10006 ] | Screened [ 10004 ] |
Rich Hickey
made changes -
| Approval | Screened [ 10004 ] | Ok [ 10007 ] |
Stuart Halloway
made changes -
| Resolution | Completed [ 1 ] | |
| Status | Open [ 1 ] | Closed [ 6 ] |
Stuart Halloway
made changes -
| Assignee | Stuart Halloway [ stu ] | |
| Status | Closed [ 6 ] | Reopened [ 4 ] |
| Resolution | Completed [ 1 ] |
Stuart Halloway
made changes -
| Approval | Ok [ 10007 ] | Not Approved [ 10008 ] |
| Issue Type | Defect [ 1 ] | Enhancement [ 4 ] |
Stuart Halloway
made changes -
| Resolution | Declined [ 2 ] | |
| Status | Reopened [ 4 ] | Closed [ 6 ] |
First of all, clojure.lang.IFn is no protocol but an interface. And it does not declare a
method. It has an `invoke` method with 20 Object parameters followed by an Object... parameter, but to give an implementation for that, you have to specify every parameter separately, and the last Object... arg is just a normal argument that must be an Object[]. That's because Java-varags Type... parameters are just Java syntax sugar, but in the byte-code its simply a Type-array.
What your example does is provide an `invoke` implementation for the 2-args version, where the first parameter happens to be named `&`, which has no special meaning here. Take that example:
(deftype MyFoo [] clojure.lang.IFn (invoke [this & xs] [& xs])) ((MyFoo.) 1 2) => [1 2]But you are right in that `deftype`, `defrecord`, `defprotocol`, and `definferface` probably should error if user's seem to try to use varargs or destructuring.
(deftype MyFoo [] clojure.lang.IFn (invoke [this & xs] [& xs])) ((MyFoo.) 1 2) => [1 2]