Created
June 13, 2010 22:13
-
-
Save swannodette/437046 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns prim-this-bug) | |
(set! *warn-on-reflection* true) | |
(defprotocol VecMath | |
(add [this other]) | |
(sub [this other])) | |
(defrecord Point [^double x ^double y] | |
VecMath | |
(add [this other] (let [^Point other other] | |
(Point. (+ x (.x other)) (+ y (.y other))))) | |
(sub [this other] (let [^Point other other] | |
(Point. (- x (.x other)) (- y (.y other)))))) | |
(defn ^:static bugfn ^double [p1 p2] | |
(let [v (sub p1 p2)] | |
(+ (:x v) (:y v)))) | |
;; error: java.lang.RuntimeException: java.lang.IllegalStateException: no 'this' pointer within static method (prim_this_bug.clj:16) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment