Last active
August 29, 2015 14:18
-
-
Save aamedina/82fee074fb2fb398d4e1 to your computer and use it in GitHub Desktop.
This file contains 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
(def ^:dynamic *start-time* (System/nanoTime)) | |
(defn elapsed-ms | |
[] | |
(/ (- (System/nanoTime) *start-time*) 1000000)) | |
(defn ^double position-offset-angle | |
([] | |
(position-offset-angle 5000)) | |
([^long duration] | |
(position-offset-angle duration (/ (* Math/PI 2.0) duration))) | |
([^long duration ^double scale] | |
(* (mod (elapsed-ms) duration) scale))) | |
;; This code will not compile: | |
;; https://gist.github.com/aamedina/3ccee6bac03c04be8d2a | |
(let [theta (position-offset-angle) | |
x-offset (* (Math/cos theta) 0.5) | |
y-offset (* (Math/sin theta) 0.5)]) | |
;; This will compile successfully | |
(let [theta (position-offset-angle)] theta) | |
;; However any let binding which references the theta local will also throw: | |
;; https://gist.github.com/aamedina/f86d059d16e9cf27b567 | |
(let [theta (position-offset-angle) | |
x-offset theta]) | |
;; The following also throws the same exception as above: | |
(let [theta (position-offset-angle)] | |
(* 5 theta)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment