TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Clojure from the ground-up: debugging

70 pointsby momo-reinaover 10 years ago

5 comments

swannodetteover 10 years ago
Kyle&#x27;s suggestions have a ton of value, but do note that debugging Clojure(Script) can also be a pedestrian activity if you so desire. All the usual mainstream bell&#x2F;whistles IDE-based interactive debugging is available today in CursiveClojure - break on all exceptions, eval in frame, etc.<p>Also ClojureScript has had accurate source mapping in Safari, Chrome, Firefox, and Node.js for quite a long time now and recently moved to support targets like iOS. It&#x27;s a huge time saver even for an experienced Clojure programmer :)
评论 #9050220 未加载
kaffeinecomaover 10 years ago
I&#x27;m trying so hard to love Clojure, but I keep running into examples of code like this in the world: <a href="http://imgur.com/79FlpTL" rel="nofollow">http:&#x2F;&#x2F;imgur.com&#x2F;79FlpTL</a>. I don&#x27;t write dense Lisp code like that, but unfortunately a lot of other people do. And I spend far more time reading code than writing it.
评论 #9049792 未加载
评论 #9049678 未加载
评论 #9050473 未加载
评论 #9049654 未加载
lispmover 10 years ago
Error messages and stack traces look pretty ugly.<p>In Common Lisp:<p><pre><code> CL-USER 51 &gt; (bake (make-instance &#x27;pie :flavor :blackberry) 375 10.25) Error: The value 3843.75 of #:|predicate1555| is not a predicate in CONDP. 1 (continue) Supply a new value of #:|predicate1555|. 2 (abort) Return to level 0. 3 Return to top loop level 0. </code></pre> A clear error message and a way to repair it.<p>A stack frame:<p><pre><code> Call to BAKE {offset 394} PIE : #&lt;PIE 402000993B&gt; TEMP : 375 TIME : 10.25 DBG::|predicate| : 3843.75 DBG::|expression| : #&lt;Function &lt; 411007995C&gt; DBG::G : 3843.75</code></pre>
评论 #9049997 未加载
lispmover 10 years ago
SBCL at compile time:<p><pre><code> * (defun bake (pie temp time) &quot;Bakes a cake for a certain amount of time, returning a cake with a new :tastiness level.&quot; (setf (tastiness pie) (condp (* temp time) #&#x27;&lt; (400 :burned) (350 :perfect) (300 :soggy)))) ; in: DEFUN BAKE ; (CONDP (* TEMP TIME) ; #&#x27;&lt; ; (400 :BURNED) ; (350 :PERFECT) ; (300 :SOGGY)) ; ==&gt; ; (LET ((#:PREDICATE2 (* TEMP TIME)) (#:EXPRESSION3 #&#x27;&lt;)) ; (DECLARE (TYPE FUNCTION #:PREDICATE2)) ; (CHECK-TYPE #:PREDICATE2 FUNCTION &quot;a predicate in CONDP&quot;) ; (COND ((FUNCALL #:PREDICATE2 #:EXPRESSION3 400) :BURNED) ; ((FUNCALL #:PREDICATE2 #:EXPRESSION3 350) :PERFECT) ; ((FUNCALL #:PREDICATE2 #:EXPRESSION3 300) :SOGGY))) ; ; caught WARNING: ; Derived type of (* TEMP TIME) is ; (VALUES NUMBER &amp;OPTIONAL), ; conflicting with its asserted type ; FUNCTION. ; See also: ; The SBCL Manual, Node &quot;Handling of Types&quot; ; ; compilation unit finished ; caught 1 WARNING condition </code></pre> Pretty cool...
Flowover 10 years ago
Does anyone know what color theme those code boxes use?<p>I apologize for being so shallow :)