Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: candera/namespaces-symbols-vars
base: 20b45d6674
...
head fork: candera/namespaces-symbols-vars
compare: df73844889
Checking mergeability… Don't worry, you can still create the pull request.
  • 6 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
Showing with 164 additions and 98 deletions.
  1. +120 −73 slides.html
  2. +44 −25 slides.org
View
193 slides.html
@@ -7,7 +7,7 @@
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"/>
<meta name="title" content="Namespaces, Vars, and Symbols (Oh, My!)"/>
<meta name="generator" content="Org-mode"/>
-<meta name="generated" content="2012-03-02 10:30:04 EST"/>
+<meta name="generated" content="2012-03-12 11:12:43 EDT"/>
<meta name="author" content="Craig Andera"/>
<meta name="description" content=""/>
<meta name="keywords" content=""/>
@@ -51,13 +51,14 @@ <h1 class="title">Namespaces, Vars, and Symbols (Oh, My!)</h1>
<li><a href="#sec-1-1-11">1.1.11 What is a Namespace?</a></li>
<li><a href="#sec-1-1-12">1.1.12 What is a Var?</a></li>
<li><a href="#sec-1-1-13">1.1.13 Creating a Var</a></li>
-<li><a href="#sec-1-1-14">1.1.14 Referring Vars</a></li>
-<li><a href="#sec-1-1-15">1.1.15 Referring Vars</a></li>
-<li><a href="#sec-1-1-16">1.1.16 Viewing Namespace Mappings</a></li>
-<li><a href="#sec-1-1-17">1.1.17 Viewing Namespace Mappings</a></li>
-<li><a href="#sec-1-1-18">1.1.18 How are Symbols Evaluated?</a></li>
-<li><a href="#sec-1-1-19">1.1.19 The Code Again</a></li>
-<li><a href="#sec-1-1-20">1.1.20 <code>ns</code></a></li>
+<li><a href="#sec-1-1-14">1.1.14 Viewing Namespace Mappings</a></li>
+<li><a href="#sec-1-1-15">1.1.15 Viewing Namespace Mappings</a></li>
+<li><a href="#sec-1-1-16">1.1.16 Where Am I?</a></li>
+<li><a href="#sec-1-1-17">1.1.17 Referring Vars</a></li>
+<li><a href="#sec-1-1-18">1.1.18 Referring Vars</a></li>
+<li><a href="#sec-1-1-19">1.1.19 How are Symbols Evaluated?</a></li>
+<li><a href="#sec-1-1-20">1.1.20 The Code Again</a></li>
+<li><a href="#sec-1-1-21">1.1.21 <code>ns</code></a></li>
</ul></li>
</ul>
</li>
@@ -318,18 +319,21 @@ <h4 id="sec-1-1-11"><span class="section-number-4">1.1.11</span> What is a Names
<div class="outline-text-4" id="text-1-1-11">
<ul>
-<li id="sec-1-1-11-1">A mapping from symbols to<br/>
+<li id="sec-1-1-11-1"><b>Conceptually</b>: A way to disambiguate names<br/>
+</li>
+</ul>
<ul>
-<li id="sec-1-1-11-1-1">Java classes<br/>
+<li id="sec-1-1-11-2"><b>Concretely</b>: A mapping from symbols to<br/>
+<ul>
+<li id="sec-1-1-11-2-1">Java classes<br/>
</li>
</ul>
<ul>
-<li id="sec-1-1-11-1-2">Vars<br/>
+<li id="sec-1-1-11-2-2">Aliases<br/>
</li>
</ul>
<ul>
-<li id="sec-1-1-11-1-3">Aliases<br/>
-
+<li id="sec-1-1-11-2-3">Vars<br/>
</li>
</ul>
@@ -390,52 +394,9 @@ <h4 id="sec-1-1-13"><span class="section-number-4">1.1.13</span> Creating a Var
</div>
<div id="outline-container-1-1-14" class="outline-4">
-<h4 id="sec-1-1-14"><span class="section-number-4">1.1.14</span> Referring Vars &nbsp;&nbsp;&nbsp;<span class="tag"><span class="fixnowrap">fixnowrap</span>&nbsp;<span class="slide">slide</span></span></h4>
+<h4 id="sec-1-1-14"><span class="section-number-4">1.1.14</span> Viewing Namespace Mappings &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
<div class="outline-text-4" id="text-1-1-14">
-<ul>
-<li id="sec-1-1-14-1">Vars from other namespaces can be mapped in<br/>
-</li>
-</ul>
-<ul>
-<li id="sec-1-1-14-2"><code>refer</code> does this<br/>
-</li>
-</ul>
-<ul>
-<li id="sec-1-1-14-3">Can pull them in selectively via <code>:only</code> or <code>:exclude</code><br/>
-
-</li>
-</ul>
-</div>
-
-</div>
-
-<div id="outline-container-1-1-15" class="outline-4">
-<h4 id="sec-1-1-15"><span class="section-number-4">1.1.15</span> Referring Vars &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
-<div class="outline-text-4" id="text-1-1-15">
-
-
-
-
-<pre class="src src-clojure"><span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer all public symbols</span>
-(<span style="color: #b0c4de;">refer</span> 'net.cgrand.enlive-html)
-
-<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer only foo and bar</span>
-(<span style="color: #b0c4de;">refer</span> '[blah.whatever <span style="color: #7fffd4;">:only</span> (foo bar)])
-
-<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer everything except defroutes and GET</span>
-(<span style="color: #b0c4de;">refer</span> '[compojure.core <span style="color: #7fffd4;">:except</span> (defroutes GET)])
-</pre>
-
-
-</div>
-
-</div>
-
-<div id="outline-container-1-1-16" class="outline-4">
-<h4 id="sec-1-1-16"><span class="section-number-4">1.1.16</span> Viewing Namespace Mappings &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
-<div class="outline-text-4" id="text-1-1-16">
-
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
@@ -460,9 +421,9 @@ <h4 id="sec-1-1-16"><span class="section-number-4">1.1.16</span> Viewing Namespa
</div>
-<div id="outline-container-1-1-17" class="outline-4">
-<h4 id="sec-1-1-17"><span class="section-number-4">1.1.17</span> Viewing Namespace Mappings &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
-<div class="outline-text-4" id="text-1-1-17">
+<div id="outline-container-1-1-15" class="outline-4">
+<h4 id="sec-1-1-15"><span class="section-number-4">1.1.15</span> Viewing Namespace Mappings &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-15">
@@ -490,11 +451,88 @@ <h4 id="sec-1-1-17"><span class="section-number-4">1.1.17</span> Viewing Namespa
</div>
+<div id="outline-container-1-1-16" class="outline-4">
+<h4 id="sec-1-1-16"><span class="section-number-4">1.1.16</span> Where Am I? &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-16">
+
+<ul>
+<li id="sec-1-1-16-1">Use <code>in-ns</code> to switch namespaces<br/>
+<ul>
+<li id="sec-1-1-16-1-1">Creates a new one if necessary<br/>
+</li>
+</ul>
+<ul>
+<li id="sec-1-1-16-1-2">Mostly used from REPL<br/>
+</li>
+</ul>
+</li>
+</ul>
+<ul>
+<li id="sec-1-1-16-2"><code>*ns*</code> var refers to current namespace<br/>
+</li>
+</ul>
+<ul>
+<li id="sec-1-1-16-3"><code>ns</code> macro a convenience for authoring source files<br/>
+
+</li>
+</ul>
+</div>
+
+</div>
+
+<div id="outline-container-1-1-17" class="outline-4">
+<h4 id="sec-1-1-17"><span class="section-number-4">1.1.17</span> Referring Vars &nbsp;&nbsp;&nbsp;<span class="tag"><span class="fixnowrap">fixnowrap</span>&nbsp;<span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-17">
+
+<ul>
+<li id="sec-1-1-17-1">Vars from other namespaces can be mapped in<br/>
+</li>
+</ul>
+<ul>
+<li id="sec-1-1-17-2"><code>refer</code> does this<br/>
+</li>
+</ul>
+<ul>
+<li id="sec-1-1-17-3">Can pull them in selectively via <code>:only</code> or <code>:exclude</code><br/>
+
+</li>
+</ul>
+</div>
+
+</div>
+
<div id="outline-container-1-1-18" class="outline-4">
-<h4 id="sec-1-1-18"><span class="section-number-4">1.1.18</span> How are Symbols Evaluated? &nbsp;&nbsp;&nbsp;<span class="tag"><span class="fixnowrap">fixnowrap</span>&nbsp;<span class="slide">slide</span></span></h4>
+<h4 id="sec-1-1-18"><span class="section-number-4">1.1.18</span> Referring Vars &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
<div class="outline-text-4" id="text-1-1-18">
+
+
+<pre class="src src-clojure">(<span style="color: #b0c4de;">ns</span> some.where)
+
+<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer all public vars</span>
+(<span style="color: #b0c4de;">refer</span> 'net.cgrand.enlive-html)
+
+<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">No namespace required!</span>
+(render ...)
+
+<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer only foo and bar</span>
+(<span style="color: #b0c4de;">refer</span> '[blah.whatever <span style="color: #7fffd4;">:only</span> (foo bar)])
+
+<span style="color: #ff7f24;">;; </span><span style="color: #ff7f24;">Refer everything except defroutes and GET</span>
+(<span style="color: #b0c4de;">refer</span> '[compojure.core <span style="color: #7fffd4;">:except</span> (defroutes GET)])
+</pre>
+
+
+</div>
+
+</div>
+
+<div id="outline-container-1-1-19" class="outline-4">
+<h4 id="sec-1-1-19"><span class="section-number-4">1.1.19</span> How are Symbols Evaluated? &nbsp;&nbsp;&nbsp;<span class="tag"><span class="fixnowrap">fixnowrap</span>&nbsp;<span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-19">
+
+
<p>
<img src="SymbolResolution.png" alt="SymbolResolution.png" />
</p>
@@ -516,9 +554,9 @@ <h4 id="sec-1-1-18"><span class="section-number-4">1.1.18</span> How are Symbols
</div>
-<div id="outline-container-1-1-19" class="outline-4">
-<h4 id="sec-1-1-19"><span class="section-number-4">1.1.19</span> The Code Again &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
-<div class="outline-text-4" id="text-1-1-19">
+<div id="outline-container-1-1-20" class="outline-4">
+<h4 id="sec-1-1-20"><span class="section-number-4">1.1.20</span> The Code Again &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-20">
@@ -537,18 +575,18 @@ <h4 id="sec-1-1-19"><span class="section-number-4">1.1.19</span> The Code Again
</div>
-<div id="outline-container-1-1-20" class="outline-4">
-<h4 id="sec-1-1-20"><span class="section-number-4">1.1.20</span> <code>ns</code> &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
-<div class="outline-text-4" id="text-1-1-20">
+<div id="outline-container-1-1-21" class="outline-4">
+<h4 id="sec-1-1-21"><span class="section-number-4">1.1.21</span> <code>ns</code> &nbsp;&nbsp;&nbsp;<span class="tag"><span class="slide">slide</span></span></h4>
+<div class="outline-text-4" id="text-1-1-21">
<pre class="src src-clojure">(<span style="color: #b0c4de;">ns</span> foo.bar
- (<span style="color: #7fffd4;">:refer-clojure</span> <span style="color: #7fffd4;">:exclude</span> [ancestors printf])
- (<span style="color: #7fffd4;">:require</span> (clojure test test.junit))
- (<span style="color: #7fffd4;">:use</span> (my.lib this that))
+ (<span style="color: #7fffd4;">:refer-clojure</span> <span style="color: #7fffd4;">:exclude</span> [replace])
+ (<span style="color: #7fffd4;">:require</span> clojure.test)
+ (<span style="color: #7fffd4;">:use</span> [clojure.string <span style="color: #7fffd4;">:only</span> (<span style="color: #eedd82;">replace</span> join)])
(<span style="color: #7fffd4;">:import</span> (java.util <span style="color: #b0c4de;">Date</span> <span style="color: #b0c4de;">Timer</span> <span style="color: #b0c4de;">Random</span>)
<span style="color: #b0c4de;">java.sql.Connection</span>))
</pre>
@@ -607,7 +645,7 @@ <h4 id="sec-2-1-2"><span class="section-number-4">2.1.2</span> Using vars &nbsp;
<pre class="src src-clojure">(<span style="color: #b0c4de;">ns</span> hello-world
- (<span style="color: #7fffd4;">:use</span> compojure.core, ring.adapter.jetty))
+ (<span style="color: #7fffd4;">:use</span> compojure.core ring.adapter.jetty))
(defroutes main-routes ...)
@@ -660,8 +698,17 @@ <h4 id="sec-2-1-4"><span class="section-number-4">2.1.4</span> Circular Dependen
(<span style="color: #b0c4de;">ns</span> one
(<span style="color: #7fffd4;">:require</span> two))
-(<span style="color: #b0c4de;">ns</span> two
+(<span style="color: #00ffff;">defn</span> <span style="color: #87cefa;">a</span> [] (two/b))
+</pre>
+
+
+
+<pre class="src src-clojure">(<span style="color: #b0c4de;">ns</span> two
(<span style="color: #7fffd4;">:require</span> one))
+
+(<span style="color: #00ffff;">defn</span> <span style="color: #87cefa;">b</span> [] <span style="color: #ffa07a;">"It worked!"</span>)
+
+(<span style="color: #00ffff;">defn</span> <span style="color: #87cefa;">c</span> [] (one/a))
</pre>
@@ -748,7 +795,7 @@ <h3 id="sec-2-2"><span class="section-number-3">2.2</span> Notes</h3>
</div>
<div id="postamble">
-<p class="date">Date: 2012-03-02 10:30:04 EST</p>
+<p class="date">Date: 2012-03-12 11:12:43 EDT</p>
<p class="author">Author: Craig Andera</p>
<p class="creator">Org version 7.8.03 with Emacs version 23</p>
<a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a>
View
69 slides.org
@@ -111,12 +111,11 @@
#+end_src
*** What is a Namespace? :slide:
-**** A mapping from symbols to
+**** *Conceptually*: A way to disambiguate names
+**** *Concretely*: A mapping from symbols to
***** Java classes
-***** Vars
***** Aliases
-
-# TODO: Show code at this point
+***** Vars
*** What is a Var? :slide:
**** An association between a name and a value
@@ -140,23 +139,6 @@
(defn bar [x] (+ 2 x))
#+end_src
-*** Referring Vars :fixnowrap:slide:
-**** Vars from other namespaces can be mapped in
-**** =refer= does this
-**** Can pull them in selectively via =:only= or =:exclude=
-
-*** Referring Vars :slide:
-#+begin_src clojure
- ;; Refer all public symbols
- (refer 'net.cgrand.enlive-html)
-
- ;; Refer only foo and bar
- (refer '[blah.whatever :only (foo bar)])
-
- ;; Refer everything except defroutes and GET
- (refer '[compojure.core :except (defroutes GET)])
-#+end_src
-
*** Viewing Namespace Mappings :slide:
# The \nbsp in the table entries is to prevent org-mode from treating
@@ -190,6 +172,35 @@
#+end_src
+*** Where Am I? :slide:
+**** Use =in-ns= to switch namespaces
+***** Creates a new one if necessary
+***** Mostly used from REPL
+**** =*ns*= var refers to current namespace
+**** =ns= macro a convenience for authoring source files
+
+*** Referring Vars :fixnowrap:slide:
+**** Vars from other namespaces can be mapped in
+**** =refer= does this
+**** Can pull them in selectively via =:only= or =:exclude=
+
+*** Referring Vars :slide:
+#+begin_src clojure
+ (ns some.where)
+
+ ;; Refer all public vars
+ (refer 'net.cgrand.enlive-html)
+
+ ;; No namespace required!
+ (render ...)
+
+ ;; Refer only foo and bar
+ (refer '[blah.whatever :only (foo bar)])
+
+ ;; Refer everything except defroutes and GET
+ (refer '[compojure.core :except (defroutes GET)])
+#+end_src
+
*** How are Symbols Evaluated? :fixnowrap:slide:
file:SymbolResolution.png
@@ -242,9 +253,9 @@ file:SymbolResolution.png
#+begin_src clojure
(ns foo.bar
- (:refer-clojure :exclude [ancestors printf])
- (:require (clojure test test.junit))
- (:use (my.lib this that))
+ (:refer-clojure :exclude [replace])
+ (:require clojure.test)
+ (:use [clojure.string :only (replace join)])
(:import (java.util Date Timer Random)
java.sql.Connection))
#+end_src
@@ -264,7 +275,7 @@ file:SymbolResolution.png
*** Using vars :slide:
#+begin_src clojure
(ns hello-world
- (:use compojure.core, ring.adapter.jetty))
+ (:use compojure.core ring.adapter.jetty))
(defroutes main-routes ...)
@@ -291,8 +302,16 @@ file:SymbolResolution.png
(ns one
(:require two))
+ (defn a [] (two/b))
+#+end_src
+
+#+begin_src clojure
(ns two
(:require one))
+
+ (defn b [] "It worked!")
+
+ (defn c [] (one/a))
#+end_src
*** Circular Dependencies :fixnowrap:slide:

No commit comments for this range

Something went wrong with that request. Please try again.