-
Notifications
You must be signed in to change notification settings - Fork 48
improvements
satyr edited this page May 27, 2011
·
22 revisions
$ git log -1 --oneline 9e4fa02 CoffeeScript 1.1.1 |
$ git log -1 --oneline 7e5344b 0.5.3 |
Coco uses them more wisely than Coffee, making generated code cleaner and/or faster.
$ coffee -bpe '[i for i in a]' var i; [ (function() { var _i, _len, _results; _results = []; for (_i = 0, _len = a.length; _i < _len; _i++) { i = a[_i]; _results.push(i); } return _results; })() ]; |
$ coco -bpe '[i for i of a]' var i; [ (function(){ var _i, _ref, _len, _results = []; for (_i = 0, _len = (_ref = a).length; _i < _len; ++_i) { i = _ref[_i]; _results.push(i); } return _results; }()) ]; |
$ coffee -bpe 'a < b() < c; d > e() > f' var _ref, _ref2; (a < (_ref = b()) && _ref < c); (d > (_ref2 = e()) && _ref2 > f); |
$ coco -bpe 'a < b() < c; d > e() > f' var _ref; a < (_ref = b()) && _ref < c; d > (_ref = e()) && _ref > f; |
$ coffee -bpe '=> this' var __bind = function(fn, me){ ... }; __bind(function() { return this; }, this); |
$ coco -bpe '~> this' var _this = this; (function(){ return _this; }); |
$ coffee -bpe 'r = for k of o then arguments' var k, r; r = (function() { var _results; _results = []; for (k in o) { _results.push(arguments); } return _results; }).apply(this, arguments); |
$ coco -bpe 'r = for k in o then arguments' var k, r; r = (function(_args){ var _results = []; for (k in o) { _results.push(_args); } return _results; }(arguments)); |
$ coffee -bpe 'Math += 1'
Math += 1;
$ coco -bpe 'Math += 1'
SyntaxError: assignment to undeclared variable "Math" on line 1
$ coffee -bpe 'a:1, a:2'
({
a: 1,
a: 2
});
$ coco -bpe 'a:1, a:2'
SyntaxError: duplicate property name "a" on line 1
$ coffee -bpe 'x = (return)'
SyntaxError: cannot use a pure statement in an expression.
...
$ coco -bpe 'x = (return)'
SyntaxError: inconvertible statement on line 1
...
$ cat space_tab.coffee
if 0
console.log 1
console.log 2
$ coffee space_tab.coffee
2
$ coco space_tab.coffee
Failed at: space_tab.coffee
SyntaxError: contaminated indent %09 on line 2
$ cat misdent.coffee
if 0
console.log 1
console.log 2
$ coffee misdent.coffee
2
$ coco misdent.coffee
Failed at: misdent.coffee
SyntaxError: unmatched dedent (2 for 4) on line 3
$ coffee -bpe '[]()'
[]();
$ coco -bpe '[]()'
SyntaxError: invalid callee on line 1
$ coffee -bpe '/+/'
/+/;
$ coco -bpe '/+/'
SyntaxError: Invalid regular expression: /+/: Nothing to repeat on line 1