Skip to content

Commit

Permalink
* resources/public/synonym.html: more
Browse files Browse the repository at this point in the history
  • Loading branch information
David Nolen authored and David Nolen committed Apr 23, 2012
1 parent d830ca7 commit 9d67e3f
Showing 1 changed file with 147 additions and 0 deletions.
147 changes: 147 additions & 0 deletions resources/public/synonym.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,153 @@ <h4>Protocols</h4>
</div>
</div>

<h3>Regular Expressions</h3>
<div class="syn-section">
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
var email = "test@example.com";
email.match(/@/)
// => ["@"]
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
(def email "test@example.com")
(.match email #"@" email)
;; => ["@"]
</pre>
</div>
</div>
</div>
<div class="syn-section">
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
var invalidEmail = "f@il@example.com";
invalidEmail.match(/@/g)
// => ["@", "@"]
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
(def invalid-email "f@il@example.com")
(.match email #"(?g)@")
;; => ["@", "@"]
</pre>
</div>
</div>
</div>


<h3>Exceptions</h3>
<div class="syn-section">
<h4>Throw an exception</h4>
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
throw Error("Oops!");
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
(throw (js/Error. "Oops!"))
</pre>
</div>
</div>
</div>

<div class="syn-section">
<h4>Catch an exception</h4>
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
try {
undefinedFunction();
} catch(e) {
if (e instanceof ReferenceError) {
console.log('You called a function'+
'that does not exist');
}
} finally {
console.log('This runs even if'+
'an exception is thrown');
}
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
(try
(undefined-function)
(catch Error e
(if (= (type e) js/ReferenceError)
(.log js/console
"You called a function that does not exist"))
(finally
(.log js/console
"this runs even if an exception is thrown"))))
</pre>
</div>
</div>
</div>

<h3>Metaprogramming</h3>
<div class="syn-section">
<h4>Runtime</h4>
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
// JavaScript is dynamic, standard runtime
// metaprogramming techniques applicable
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
// ClojureScript is dynamic, standard runtime
// metaprogramming techniques applicable
</pre>
</div>
</div>
</div>

<div class="syn-section">
<h4>Compile Time</h4>
<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
// No native implementation, must use external
// compilation tools.
</pre>
</div>
</div>

<div class="cheat-box-container eight columns">
<div class="cheat-box">
<pre>
// ClojureScript has compiler macros, no external
// tool required
(defmacro my-code-transformation [...]
...)
</pre>
</div>
</div>
</div>

<div class="rule sixteen columns"></div>

<div class="column footer-logo">Himera &copy; 2012 Fogus and Relevance Inc.</div>
Expand Down

0 comments on commit 9d67e3f

Please sign in to comment.