diff --git a/coffee-script.gemspec b/coffee-script.gemspec index 3acde9d7..ab7b493f 100644 --- a/coffee-script.gemspec +++ b/coffee-script.gemspec @@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.name = 'coffee-script' - s.version = '0.1.2' # Keep version in sync with coffee-script.rb - s.date = '2009-12-24' + s.version = '0.1.3' # Keep version in sync with coffee-script.rb + s.date = '2009-12-25' s.homepage = "http://jashkenas.github.com/coffee-script/" s.summary = "The CoffeeScript Compiler" diff --git a/documentation/index.html.erb b/documentation/index.html.erb index 51256ce4..74d0c45f 100644 --- a/documentation/index.html.erb +++ b/documentation/index.html.erb @@ -37,8 +37,6 @@ equivalent in JavaScript, it's just another way of saying it.

- -

Disclaimer: CoffeeScript is just for fun and seriously alpha. I'm sure that there are still @@ -95,14 +93,31 @@ gem install coffee-script

Installing the gem provides the coffee-script command, which can be used to compile CoffeeScript .cs files into JavaScript, as - well as debug them. By default, coffee-script writes out the - JavaScript as .js files in the same directory, but output + well as debug them. In conjunction with + Narwhal, the coffee-script + command also provides direct evaluation and an interactive REPL. + When compiling to JavaScript, coffee-script writes the output + as .js files in the same directory by default, but output can be customized with the following options:

- + + + + + + + + + @@ -427,6 +442,20 @@ coffee-script --print app/scripts/*.cs > concatenation.js

Change Log

+ +

+ 0.1.3 + The coffee-script command now includes --interactive, + which launches an interactive CoffeeScript session, and --run, + which directly compiles and executes a script. Both options depend on a + working installation of Narwhal. + The aint keyword has been replaced by isnt, which goes + together a little smoother with is. + Quoted strings are now allowed as identifiers within object literals: eg. + {"5+5": 10}. + All assignment operators now use a colon: +:, -:, + *:, etc. +

0.1.2 diff --git a/documentation/js/array_comprehensions.js b/documentation/js/array_comprehensions.js index 3fcbd836..e1835a2f 100644 --- a/documentation/js/array_comprehensions.js +++ b/documentation/js/array_comprehensions.js @@ -2,18 +2,18 @@ // Eat lunch. var lunch; - var a = ['toast', 'cheese', 'wine']; - var d = []; - for (var b=0, c=a.length; b - -

Disclaimer: CoffeeScript is just for fun and seriously alpha. I'm sure that there are still @@ -112,13 +110,13 @@ cubed_list: math.cube(num) fo }; // Array comprehensions: var cubed_list; -var a = list; -var d = []; -for (var b=0, c=a.length; b<c; b++) { - var num = a[b]; - d[b] = math.cube(num); +var __a = list; +var __d = []; +for (var __b=0, __c=__a.length; __b<__c; __b++) { + var num = __a[__b]; + __d[__b] = math.cube(num); } -cubed_list = d; +cubed_list = __d;

Installation and Usage

- +

The CoffeeScript compiler is written in pure Ruby, and is available as a Ruby Gem. @@ -165,14 +163,31 @@ gem install coffee-script

Installing the gem provides the coffee-script command, which can be used to compile CoffeeScript .cs files into JavaScript, as - well as debug them. By default, coffee-script writes out the - JavaScript as .js files in the same directory, but output + well as debug them. In conjunction with + Narwhal, the coffee-script + command also provides direct evaluation and an interactive REPL. + When compiling to JavaScript, coffee-script writes the output + as .js files in the same directory by default, but output can be customized with the following options:

-o, --output [DIR]-i, --interactive + Launch an interactive CoffeeScript session. + Requires Narwhal. +
-r, --run + Compile and execute the CoffeeScripts without saving the intermediate + JavaScript. Requires Narwhal. +
-o, --output [DIR] Write out all compiled JavaScript files into the specified directory.
- + + + + + + + + + @@ -195,7 +210,7 @@ gem install coffee-script @@ -264,15 +279,15 @@ coffee-script --print app/scripts/*.cs > concatenation.js the line will do just as well. All other whitespace is not significant. Instead of using curly braces { } to delimit a block of code, use a period . to mark the end of a - block, for - functions, - if-statements, + block, for + functions, + if-statements, switch, and try/catch.

Functions and Invocation - Functions are defined by a list of parameters, an arrow, and the + Functions are defined by a list of parameters, an arrow, and the function body. The empty function looks like this: =>.

square: x => x * x.
@@ -453,7 +468,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";
       The same mechanism is used to push down assignment through switch
       statements, and if-elses (although the ternary operator is preferred).
     

- +

Aliases Because the == operator frequently causes undesirable coercion, @@ -472,7 +487,7 @@ var eldest = 24 > 21 ? "Liz" : "Ike";

Instead of a newline or semicolon, then can be used to separate - conditions from expressions, in while, + conditions from expressions, in while, if/else, and switch/when statements.

@@ -543,18 +558,18 @@ highlight(row) for row, i in<

 // Eat lunch.
 var lunch;
-var a = ['toast', 'cheese', 'wine'];
-var d = [];
-for (var b=0, c=a.length; b<c; b++) {
-  var food = a[b];
-  d[b] = food.eat();
+var __a = ['toast', 'cheese', 'wine'];
+var __d = [];
+for (var __b=0, __c=__a.length; __b<__c; __b++) {
+  var food = __a[__b];
+  __d[__b] = food.eat();
 }
-lunch = d;
+lunch = __d;
 // Zebra-stripe a table.
-var e = table;
-for (var f=0, g=e.length; f<g; f++) {
-  var row = e[f];
-  var i = f;
+var __e = table;
+for (var __f=0, __g=__e.length; __f<__g; __f++) {
+  var row = __e[__f];
+  var i = __f;
   i % 2 === 0 ? highlight(row) : null;
 }
 

@@ -769,14 +784,14 @@ to interest me on shore, I thought I would sail \ about a little and see the watery part of the \ world..."; ;alert(moby_dick);'>run: moby_dick
- +

Contributing

- +

Here's a wish list of things that would be wonderful to have in CoffeeScript:

- + - +

Change Log

+

+ 0.1.3 + The coffee-script command now includes --interactive, + which launches an interactive CoffeeScript session, and --run, + which directly compiles and executes a script. Both options depend on a + working installation of Narwhal. + The aint keyword has been replaced by isnt, which goes + together a little smoother with is. + Quoted strings are now allowed as identifiers within object literals: eg. + {"5+5": 10}. + All assignment operators now use a colon: +:, -:, + *:, etc. +

+

0.1.2 - Fixed a bug with calling super() through more than one level of + Fixed a bug with calling super() through more than one level of inheritance, with the re-addition of the extends keyword. - Added experimental Narwhal - support (as a Tusk package), contributed by + Added experimental Narwhal + support (as a Tusk package), contributed by Tom Robinson, including bin/cs as a CoffeeScript REPL and interpreter. New --no-wrap option to suppress the safety function wrapper.

- +

0.1.1 Added instanceof and typeof as operators.

- +

0.1.0 Initial CoffeeScript release. diff --git a/lib/coffee-script.rb b/lib/coffee-script.rb index 29deca23..6ae826e6 100644 --- a/lib/coffee-script.rb +++ b/lib/coffee-script.rb @@ -9,7 +9,7 @@ require "coffee_script/parse_error" # Namespace for all CoffeeScript internal classes. module CoffeeScript - VERSION = '0.1.2' # Keep in sync with the gemspec. + VERSION = '0.1.3' # Keep in sync with the gemspec. # Compile a script (String or IO) to JavaScript. def self.compile(script, options={}) diff --git a/package.json b/package.json index e81ae93d..32dfd32d 100644 --- a/package.json +++ b/package.json @@ -5,5 +5,5 @@ "description": "Unfancy JavaScript", "keywords": ["javascript", "language"], "author": "Jeremy Ashkenas", - "version": "0.1.2" + "version": "0.1.3" }

-o, --output [DIR]-i, --interactive + Launch an interactive CoffeeScript session. + Requires Narwhal. +
-r, --run + Compile and execute the CoffeeScripts without saving the intermediate + JavaScript. Requires Narwhal. +
-o, --output [DIR] Write out all compiled JavaScript files into the specified directory. -l, --lint If the jsl (JavaScript Lint) command is installed, use it - to check the compilation of a CoffeeScript file. (Handy in + to check the compilation of a CoffeeScript file. (Handy in conjunction with --watch)