Clojure Notes--Cdt, Piccolo 1

Context: installing the Emacs front-end for the Clojure Development Kit installation (see http://georgejahad.com/clojure/emacs-cdt.html).

I'm having some trouble with the installation, especially with getting Leiningen to pull in its dependencies. I had just been using git and was in the git-bash shell. For some reason, things weren't working—I got a "No such file or directory" error for lein. I tried the same thing from a Windows shell and it worked just fine.


Context: Beginning use of mozinator's clj-piccolo2d Clojure "wrapper" for piccolo2d graphics library (see http://www.clojars.org/overtone/clj-piccolo2d and http://www.piccolo2d.org/index.html, respectively)

I started with a working program and began changing things, one by one. In the two lines below, the first method works, while the second method doesn't:

;  (:use clj-piccolo2d.core))
  (:use '[clj-piccolo2d.core :only (rectangle add! width height)]))

The error message from using the uncommented line above is as follows:

C:\tech\cljprojects\piccolotest1>lein run piccolotest1.core
lein run piccolotest1.core
Exception in thread "main" java.lang.Exception: lib names inside prefix lists
must not contain periods (core.clj:15)

According to http://clojure-log.n01se.net/date/2010-09-17.html (just before time mark 6:50), the error comes from the fact that symbols cannot currently contain periods in them.

For the moment, I'll go back to using the simpler :use statement.


10/24/10

An example of destructuring in the argument list (ignore the function names):

(defn make-PText
  "Make a PText object w/optional text, font"
  [& [text font]]
  (println "text=" text ", font=" font))

(make-PText "hello" (make-font "Monospaced" Font/PLAIN 36))
(make-PText "hello")
(make-PText)

The three tests return the following:

text= hello , font= #<Font java.awt.Font[family=Monospaced, 
    name=Monospaced,style=plain,size=36]>
text= hello , font= nil
text= nil , font= nil

Note that if the value expected within the arg sequence doesn't exist, the value returned is nil.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License