Skip to content

Commit

Permalink
CoffeeScript 0.2.6 is on the books
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Jan 17, 2010
1 parent 80fbe02 commit 63c9b5c
Show file tree
Hide file tree
Showing 17 changed files with 157 additions and 58 deletions.
4 changes: 2 additions & 2 deletions coffee-script.gemspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'coffee-script'
s.version = '0.2.5' # Keep version in sync with coffee-script.rb
s.date = '2010-1-13'
s.version = '0.2.6' # Keep version in sync with coffee-script.rb
s.date = '2010-1-17'

s.homepage = "http://jashkenas.github.com/coffee-script/"
s.summary = "The CoffeeScript Compiler"
Expand Down
5 changes: 5 additions & 0 deletions documentation/coffee/comparisons.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cholesterol: 127

healthy: 200 > cholesterol > 60


9 changes: 8 additions & 1 deletion documentation/coffee/existence.coffee
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
solipsism: true if mind? and not world?
solipsism: true if mind? and not world?

speed ?= 140





2 changes: 1 addition & 1 deletion documentation/coffee/functions.coffee
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
square: x => x * x
cube: x => square(x) * x
cube: x => square(x) * x
45 changes: 37 additions & 8 deletions documentation/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

<p>
<b>Latest Version:</b>
<a href="http://gemcutter.org/gems/coffee-script">0.2.5</a>
<a href="http://gemcutter.org/gems/coffee-script">0.2.6</a>
</p>

<h2>Table of Contents</h2>
Expand All @@ -65,7 +65,7 @@
<a href="#objects_and_arrays">Objects and Arrays</a><br />
<a href="#lexical_scope">Lexical Scoping and Variable Safety</a><br />
<a href="#conditionals">Conditionals, Ternaries, and Conditional Assignment</a><br />
<a href="#existence">The Existence Operator</a><br />
<a href="#existence">The Existential Operator</a><br />
<a href="#aliases">Aliases</a><br />
<a href="#splats">Splats...</a><br />
<a href="#arguments">Arguments are Arrays</a><br />
Expand All @@ -80,6 +80,7 @@
<a href="#embedded">Embedded JavaScript</a><br />
<a href="#switch">Switch/When/Else</a><br />
<a href="#try">Try/Catch/Finally</a><br />
<a href="#comparisons">Chained Comparisons</a><br />
<a href="#strings">Multiline Strings and Heredocs</a><br />
<a href="#resources">Resources</a><br />
<a href="#contributing">Contributing</a><br />
Expand Down Expand Up @@ -258,7 +259,8 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<b class="header">Functions and Invocation</b>
Functions are defined by a list of parameters, an arrow, and the
function body. The empty function looks like this: <tt>=></tt>. All
functions in CoffeeScript are named, for the benefit of debug messages.
functions in CoffeeScript are named by default, for the benefit of debug messages.
If you'd like to create an anonymous function, just wrap it in parentheses.
</p>
<%= code_for('functions', 'cube(5)') %>

Expand Down Expand Up @@ -329,14 +331,18 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
</p>

<p id="existence">
<b class="header">The Existence Operator</b>
<b class="header">The Existential Operator</b>
It's a little difficult to check for the existence of a variable in
JavaScript. <tt>if (variable) ...</tt> comes close, but fails for zero,
the empty string, and false. The existence operator <tt>?</tt> returns true unless
the empty string, and false. The existential operator <tt>?</tt> returns true unless
a variable is <b>null</b> or <b>undefined</b>, which makes it analogous
to Ruby's <tt>nil?</tt>
</p>
<%= code_for('existence') %>
<p>
It can also be used for safer conditional assignment than <tt>||=</tt>
provides, for cases where you may be handling numbers or strings.
</p>
<%= code_for('existence', 'speed') %>

<p id="aliases">
<b class="header">Aliases</b>
Expand Down Expand Up @@ -473,6 +479,12 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
into a function call:
</p>
<%= code_for('expressions_try', true) %>
<p>
There are a handful of statements in JavaScript that can't be meaningfully
converted into expressions: <tt>break</tt>, <tt>continue</tt>,
and <tt>return</tt>. If you make use of them within a block of code,
CoffeeScript won't try to perform the conversion.
</p>

<p id="inheritance">
<b class="header">Inheritance, and Calling Super from a Subclass</b>
Expand Down Expand Up @@ -575,6 +587,15 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
</p>
<%= code_for('try') %>

<p id="comparisons">
<b class="header">Chained Comparisons</b>
CoffeeScript borrows
<a href="http://docs.python.org/reference/expressions.html#notin">chained comparisons</a>
from Python &mdash; making it easy to test if a value falls within a
certain range.
</p>
<%= code_for('comparisons', 'healthy') %>

<p id="strings">
<b class="header">Multiline Strings and Heredocs</b>
Multiline strings are allowed in CoffeeScript.
Expand Down Expand Up @@ -612,7 +633,7 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
</li>
<li>
<a href="http://github.com/inem/coffee-haml-filter">coffee-haml-filter</a><br />
A custom <a href="http://haml-lang.com/">HAML</a> filter, by
A custom <a href="http://haml-lang.com/">HAML</a> filter, by
<a href="http://github.com/inem">Ivan Nemytchenko</a>, that embeds
snippets of CoffeeScript within your HAML templates.
</li>
Expand Down Expand Up @@ -651,6 +672,14 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>

<h2 id="change_log">Change Log</h2>

<p>
<b class="header" style="margin-top: 20px;">0.2.6</b>
Added Python-style chained comparisons, the conditional existence
operator <tt>?=</tt>, and some examples from <i>Beautiful Code</i>.
Bugfixes relating to statement-to-expression conversion, arguments-to-array
conversion, and the TextMate syntax highlighter.
</p>

<p>
<b class="header" style="margin-top: 20px;">0.2.5</b>
The conditions in switch statements can now take multiple values at once &mdash;
Expand Down Expand Up @@ -703,7 +732,7 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<b class="header" style="margin-top: 20px;">0.2.0</b>
Major release. Significant whitespace. Better statement-to-expression
conversion. Splats. Splice literals. Object comprehensions. Blocks.
The existence operator. Many thanks to all the folks who posted issues,
The existential operator. Many thanks to all the folks who posted issues,
with special thanks to
<a href="http://github.com/kamatsu">Liam O'Connor-Davis</a> for whitespace
and expression help.
Expand Down
3 changes: 2 additions & 1 deletion documentation/js/arguments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
(function(){
var backwards;
backwards = function backwards() {
return alert(Array.prototype.slice.call(arguments, 0).reverse());
var arguments = Array.prototype.slice.call(arguments, 0);
return alert(arguments.reverse());
};
backwards("stairway", "to", "heaven");
})();
5 changes: 5 additions & 0 deletions documentation/js/comparisons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
(function(){
var cholesterol, healthy;
cholesterol = 127;
healthy = (200 > cholesterol) && (cholesterol > 60);
})();
2 changes: 1 addition & 1 deletion documentation/js/conditionals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(){
var date, mood;
var date, expensive, mood;
if (singing) {
mood = greatly_improved;
}
Expand Down
3 changes: 2 additions & 1 deletion documentation/js/existence.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
(function(){
var solipsism;
var solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
solipsism = true;
}
speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;
})();
2 changes: 1 addition & 1 deletion documentation/js/expressions_assignment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(){
var one, six, three, two;
six = (one = 1) + (two = 2) + (three = 3);
six = ((one = 1)) + ((two = 2)) + ((three = 3));
})();
4 changes: 1 addition & 3 deletions documentation/js/long_arrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
this.cart = cart;
__a = $('.shopping_cart').bind('click', (function(__this) {
var __func = function(event) {
var __b;
__b = this.customer.purchase(this.cart);
return Account === this.constructor ? this : __b;
return this.customer.purchase(this.cart);
};
return (function() {
return __func.apply(__this, arguments);
Expand Down
2 changes: 1 addition & 1 deletion documentation/js/splats.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function(){
var contenders, gold, medalists, silver, the_field;
gold = silver = the_field = "unknown";
gold = (silver = (the_field = "unknown"));
medalists = function medalists(first, second) {
var rest;
rest = Array.prototype.slice.call(arguments, 2);
Expand Down
3 changes: 1 addition & 2 deletions documentation/js/super.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function(){
var Animal, Horse, Snake, __a, __b, sam, tom;
Animal = function Animal() {
};
Animal = function Animal() { };
Animal.prototype.move = function move(meters) {
return alert(this.name + " moved " + meters + "m.");
};
Expand Down
Loading

0 comments on commit 63c9b5c

Please sign in to comment.