view 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
line wrap: on
line source
1 (ns clojureDemo.WiredDemo
2 (
3 :gen-class
4 :implements [connections.WiredBox]
5 :methods [ [process [Object] void]]
6 :post-init register
7 )
8 )
11 (defn -register [this]
13 ; translate:
14 ; Connections.getPorts(this).addSignalProcessor("process");
15 ; ---- to -----
17 (println "ClojureBox (register) : Register is run only when the object is created, like a constructor.")
19 (. (connections.Connections/getPorts this) addSignalProcessor "process")
22 )
25 (defn -process [ _ _ ]
26 (println "ClojureBox (process) : This is a LISP function, being called through Java, through the wiredBox metaphor.")
27 )
32 (
33 defn -getName [_] "ClojureBox"
35 ; the [_] means that the function gets an explicit "this" argument, like python,
36 ; but we don't care about it.
38 )