Mercurial > lasercutter
comparison src/clojureDemo/WiredDemo.clj @ 1:6d9bdaf919f7
added clojureDemo source
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 20 Aug 2010 00:32:44 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:163bf9b2fd13 | 1:6d9bdaf919f7 |
---|---|
1 (ns clojureDemo.WiredDemo | |
2 ( | |
3 :gen-class | |
4 :implements [connections.WiredBox] | |
5 :methods [ [process [Object] void]] | |
6 :post-init register | |
7 ) | |
8 ) | |
9 | |
10 | |
11 (defn -register [this] | |
12 | |
13 ; translate: | |
14 ; Connections.getPorts(this).addSignalProcessor("process"); | |
15 ; ---- to ----- | |
16 | |
17 (println "ClojureBox (register) : Register is run only when the object is created, like a constructor.") | |
18 | |
19 (. (connections.Connections/getPorts this) addSignalProcessor "process") | |
20 | |
21 | |
22 ) | |
23 | |
24 | |
25 (defn -process [ _ _ ] | |
26 (println "ClojureBox (process) : This is a LISP function, being called through Java, through the wiredBox metaphor.") | |
27 ) | |
28 | |
29 | |
30 | |
31 | |
32 ( | |
33 defn -getName [_] "ClojureBox" | |
34 | |
35 ; the [_] means that the function gets an explicit "this" argument, like python, | |
36 ; but we don't care about it. | |
37 | |
38 ) | |
39 | |
40 |