Permalink
Browse files

Site updated at 2012-12-12 07:31:45 UTC

  • Loading branch information...
1 parent 174629e commit 3e06605537f31fb34b25e5109897607039bb688e @reniclin committed Dec 12, 2012
View
@@ -4,7 +4,7 @@
<title><![CDATA[Renic Lin]]></title>
<link href="http://reniclin.github.com/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -293,7 +293,7 @@ <h1 class="entry-title">Clojure Building Standalone Jar With Leiningen</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -332,7 +332,7 @@ <h1 class="entry-title">Clojure Noir Getting Start</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -291,7 +291,7 @@ <h1 class="entry-title">ClojureScript Method Call and Property Access Syntax</h1
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -303,7 +303,7 @@ <h1 class="entry-title">Web-todo</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -267,7 +267,7 @@ <h1 class="entry-title">Clojure Read a File as a Sequence of Lines</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -213,6 +213,12 @@ <h1 class="entry-title">Clojure Proxy vs Reify</h1>
<time datetime="2012-12-12T14:10:00+08:00" pubdate data-updated="true">Dec 12<span>th</span>, 2012</time>
+<span class="categories">
+
+ <a class='category' href='/blog/categories/clojure/'>clojure</a>
+
+</span>
+
</p>
@@ -323,7 +329,7 @@ <h1 class="entry-title">Clojure Proxy vs Reify</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
View
@@ -173,7 +173,7 @@ <h1 class="entry-title">About Me</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
View
@@ -10,9 +10,8 @@
<meta name="description" content="Blog Archive 2012 Clojure proxy vs reify
-Dec 12 2012 Clojure Read a File as a Sequence of Lines
-Dec 11 2012 posted in clojure web-todo
-Aug 27 2012 &hellip;">
+Dec 12 2012 posted in clojure Clojure Read a File as a Sequence of Lines
+Dec 11 2012 posted in clojure web- &hellip;">
<!-- http://t.co/dKP3o1e -->
@@ -89,6 +88,10 @@ <h1 class="entry-title">Blog Archive</h1>
<h1><a href="/blog/2012/12/12/clojure-proxy-vs-reify/">Clojure proxy vs reify</a></h1>
<time datetime="2012-12-12T14:10:00+08:00" pubdate><span class='month'>Dec</span> <span class='day'>12</span> <span class='year'>2012</span></time>
+<footer>
+ <span class="categories">posted in <a class='category' href='/blog/categories/clojure/'>clojure</a></span>
+</footer>
+
</article>
@@ -246,7 +249,7 @@ <h1 class="entry-title">Blog Archive</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: clojure | Renic Lin]]></title>
<link href="http://reniclin.github.com/blog/categories/clojure/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -14,6 +14,121 @@
<entry>
+ <title type="html"><![CDATA[Clojure proxy vs reify]]></title>
+ <link href="http://reniclin.github.com/blog/2012/12/12/clojure-proxy-vs-reify/"/>
+ <updated>2012-12-12T14:10:00+08:00</updated>
+ <id>http://reniclin.github.com/blog/2012/12/12/clojure-proxy-vs-reify</id>
+ <content type="html"><![CDATA[<h2>Clojure的proxy和reify</h2>
+
+<br />
+
+
+
+
+<!-- more -->
+
+
+<p>這個問題是在用Clojure + awt/swing開發GUI程式時遇到的,</p>
+
+<h6>(為什麼用awt/swing而不用 <a href="https://github.com/daveray/seesaw">seesaw</a> ?因為我要用到SystemTray, seesaw沒有wrapper它,加上我的程式很小。)</h6>
+
+<p>用到像是<code>JButton</code>這種元件時,常會需要用<code>addActionListener</code>method 來 add<code>ActionListener</code>。</p>
+
+<br />
+
+
+<h5>Java的寫法如下:</h5>
+
+<p><div class='bogus-wrapper'><notextile><figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
+<span class='line-number'>2</span>
+<span class='line-number'>3</span>
+<span class='line-number'>4</span>
+<span class='line-number'>5</span>
+<span class='line-number'>6</span>
+<span class='line-number'>7</span>
+<span class='line-number'>8</span>
+</pre></td><td class='code'><pre><code class='java'><span class='line'><span class="n">myJButton</span><span class="o">.</span><span class="na">addActionListener</span><span class="o">(</span><span class="k">new</span> <span class="n">ActionListener</span><span class="o">()</span> <span class="o">{&lt;/</span><span class="n">p</span><span class="o">&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="o">&lt;</span><span class="n">pre</span><span class="o">&gt;&lt;</span><span class="n">code</span><span class="o">&gt;</span><span class="kd">public</span> <span class="kt">void</span> <span class="n">actionPerformed</span><span class="o">(</span><span class="n">ActionEvent</span> <span class="n">e</span><span class="o">)</span> <span class="o">{</span>
+</span><span class='line'> <span class="c1">// do something here</span>
+</span><span class='line'><span class="o">}</span>
+</span><span class='line'><span class="o">&lt;/</span><span class="n">code</span><span class="o">&gt;&lt;/</span><span class="n">pre</span><span class="o">&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="o">&lt;</span><span class="n">p</span><span class="o">&gt;});</span>
+</span></code></pre></td></tr></table></div></figure></notextile></div></p>
+
+<br />
+
+
+<h3>在Clojure中有兩種寫法,分別是用<code>proxy</code>和<code>reify</code>。</h3>
+
+<h3>proxy</h3>
+
+<p><div class='bogus-wrapper'><notextile><figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
+<span class='line-number'>2</span>
+<span class='line-number'>3</span>
+<span class='line-number'>4</span>
+<span class='line-number'>5</span>
+<span class='line-number'>6</span>
+<span class='line-number'>7</span>
+<span class='line-number'>8</span>
+<span class='line-number'>9</span>
+</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="nf">.addActionListener</span> <span class="nv">my-jbutton&lt;/p&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="nv">&lt;pre&gt;&lt;code&gt;</span> <span class="p">(</span><span class="nb">proxy </span><span class="p">[</span><span class="nv">ActionListener</span><span class="p">]</span> <span class="p">[]</span>
+</span><span class='line'> <span class="p">(</span><span class="nf">actionPerformed</span> <span class="p">[</span><span class="nv">evt</span><span class="p">]</span>
+</span><span class='line'> <span class="c1">;; (do something here)</span>
+</span><span class='line'> <span class="p">)))</span>
+</span><span class='line'><span class="nv">&lt;/code&gt;&lt;/pre&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="nv">&lt;p&gt;</span>
+</span></code></pre></td></tr></table></div></figure></notextile></div></p>
+
+<h3>reify</h3>
+
+<p><div class='bogus-wrapper'><notextile><figure class='code'> <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class='line-number'>1</span>
+<span class='line-number'>2</span>
+<span class='line-number'>3</span>
+<span class='line-number'>4</span>
+<span class='line-number'>5</span>
+<span class='line-number'>6</span>
+<span class='line-number'>7</span>
+<span class='line-number'>8</span>
+<span class='line-number'>9</span>
+</pre></td><td class='code'><pre><code class='clojure'><span class='line'><span class="p">(</span><span class="nf">.addActionListener</span> <span class="nv">my-jbutton&lt;/p&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="nv">&lt;pre&gt;&lt;code&gt;</span> <span class="p">(</span><span class="nf">reify</span> <span class="nv">ActionListener</span>
+</span><span class='line'> <span class="p">(</span><span class="nf">actionPerformed</span> <span class="p">[</span><span class="nv">this</span> <span class="nv">evt</span><span class="p">]</span>
+</span><span class='line'> <span class="c1">;; (do something here)</span>
+</span><span class='line'> <span class="p">)))</span>
+</span><span class='line'><span class="nv">&lt;/code&gt;&lt;/pre&gt;</span>
+</span><span class='line'>
+</span><span class='line'><span class="nv">&lt;p&gt;</span>
+</span></code></pre></td></tr></table></div></figure></notextile></div></p>
+
+<br />
+
+
+<h6><code>proxy</code>和<code>reify</code>一般都是用在實作interfaces,參考網路上的幾篇文章,講到平常大部份都使用時都用<code>reify</code>就好,</h6>
+
+<h6>除了一些特別的用途才用<code>proxy</code>。(ig. override base class methods)</h6>
+
+<h4>很大概的找一下資料,要再更深入研究一下<code>proxy</code>和<code>reify</code>的異同和主要用在哪些不一樣的地方。</h4>
+
+<br />
+
+
+<h3>參考</h3>
+
+<ul>
+<li><a href="http://stackoverflow.com/questions/5821892/why-should-i-use-reify-instead-of-proxy-in-clojure">Why should I use Reify instead of proxy in clojure?</a></li>
+<li><a href="http://pepijndevos.nl/how-reify-works-and-how-to-write-a-custom-typ/index.html">How reify works, and how to write a custom type</a></li>
+</ul>
+
+]]></content>
+ </entry>
+
+ <entry>
<title type="html"><![CDATA[Clojure Read a File as a Sequence of Lines]]></title>
<link href="http://reniclin.github.com/blog/2012/12/11/clojure-read-a-file-as-a-sequence-of-lines/"/>
<updated>2012-12-11T09:04:00+08:00</updated>
@@ -83,6 +83,20 @@ <h1 class="entry-title">Category: Clojure</h1>
<article>
+<h1><a href="/blog/2012/12/12/clojure-proxy-vs-reify/">Clojure proxy vs reify</a></h1>
+<time datetime="2012-12-12T14:10:00+08:00" pubdate><span class='month'>Dec</span> <span class='day'>12</span> <span class='year'>2012</span></time>
+
+<footer>
+ <span class="categories">posted in <a class='category' href='/blog/categories/clojure/'>clojure</a></span>
+</footer>
+
+
+</article>
+
+
+
+<article>
+
<h1><a href="/blog/2012/12/11/clojure-read-a-file-as-a-sequence-of-lines/">Clojure Read a File as a Sequence of Lines</a></h1>
<time datetime="2012-12-11T09:04:00+08:00" pubdate><span class='month'>Dec</span> <span class='day'>11</span> <span class='year'>2012</span></time>
@@ -205,7 +219,7 @@ <h1 class="entry-title">Category: Clojure</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: clojurescript | Renic Lin]]></title>
<link href="http://reniclin.github.com/blog/categories/clojurescript/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -191,7 +191,7 @@ <h1 class="entry-title">Category: Clojurescript</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: jar | Renic Lin]]></title>
<link href="http://reniclin.github.com/blog/categories/jar/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -177,7 +177,7 @@ <h1 class="entry-title">Category: Jar</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: leiningen | Renic Lin]]></title>
<link href="http://reniclin.github.com/blog/categories/leiningen/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -191,7 +191,7 @@ <h1 class="entry-title">Category: Leiningen</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
@@ -4,7 +4,7 @@
<title><![CDATA[Category: noir | Renic Lin]]></title>
<link href="http://reniclin.github.com/blog/categories/noir/atom.xml" rel="self"/>
<link href="http://reniclin.github.com/"/>
- <updated>2012-12-12T15:28:34+08:00</updated>
+ <updated>2012-12-12T15:31:10+08:00</updated>
<id>http://reniclin.github.com/</id>
<author>
<name><![CDATA[Renic Lin]]></name>
@@ -177,7 +177,7 @@ <h1 class="entry-title">Category: Noir</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
View
@@ -197,7 +197,7 @@ <h1 class="entry-title"><a href="/blog/2012/07/23/clojure-building-standalone-ja
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
View
@@ -184,7 +184,7 @@ <h1 class="entry-title">Bookmarks</h1>
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
View
@@ -374,7 +374,7 @@ <h1 class="entry-title"><a href="/blog/2012/07/23/clojure-noir-getting-start/">C
<section>
<h1>Categories</h1>
<ul id="categories">
- <li class='category'><a href='/blog/categories/clojure/'>clojure (3)</a></li>
+ <li class='category'><a href='/blog/categories/clojure/'>clojure (4)</a></li>
<li class='category'><a href='/blog/categories/clojurescript/'>clojurescript (2)</a></li>
<li class='category'><a href='/blog/categories/jar/'>jar (1)</a></li>
<li class='category'><a href='/blog/categories/leiningen/'>leiningen (2)</a></li>
Oops, something went wrong.

0 comments on commit 3e06605

Please sign in to comment.