[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
Permalink

Comparing changes

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

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
base repository: jashkenas/coffeescript
Choose a Base Repository
jashkenas/coffeescript
CDR2003/coffee-script-lua
CircleCode/coffee-script
Crylock/coffee-script
GeoffreyBooth/coffeescript
Gregg/coffee-script
JamesTryand/coffee-script
JustinTulloss/coffee-script
LittleForker/coffee-script
MichaelBlume/coffee-script
NightMigera/coffeescript
ProximaMonkey/coffee-script
SE7ENSKY/matescript
STRd6/coffee-script
StanAngeloff/coffee-script
Thorsson/coffee-script
TobiaszCudnik/coffeescript-to-typescript
Xavura/coffee-script
Xepo/coffee-script
agnoster/coffee-script
akiellor/coffee-script
alanning/coffee-script
allanberger/coffee-script
almost/coffee-script
alubbe/coffee-script
andrewschaaf/coffee-script
andreypopp/coffee-script
anibal/coffee-script
apanda/coffee-script
baoshitang/coffee-script
barberboy/coffee-script
benbria/coffee-script
benekastah/coffee-script
bhuga/coffee-script
bjouhier/coffee-script
blahutka/coffee-script
blossom/coffee-script
bolinfest/coffee-script
breckinloggins/coffee-script
bsparrow435/coffee-script
burrows/coffee-script
capndesign/coffee-script
catharinejm/coffee-script
charles-cai/coffee-script
charliesome/coffee-script
chetan51/coffee-script
chip/coffee-script
codelahoma/coffee-script
coffee-js/coffee-script
coffee-void/coffeescript
collin/coffee-script
contra/yerbascript
danemorgridge/coffee-script
daveclarke/coffee-script
daveyoon/coffee-script
devongovett/coffee-script
dget/coffee-script
disnet/contracts.coffee
dmohl/coffee-script
dohse/coffee-script
dougnukem/coffee-script
dpritchett/coffee-script
dqminh/coffee-script
drewlesueur/coffee-script
dylanetkin/coffee-script
ef4/coffee-script
emmalemma/coffee-script
evilpie/coffee-script
excellentdrums/coffee-script
fauzias/coffee-script
fitzgen/coffee-script
fizx/coffee-script
franc/coffee-script
frontflip/coffee-script
geraldalewis/coffee-script
germanocaldeira/coffee-script
gfodor/coffee-script
ghuntley/coffee-script
goodwink/coffee-script
hayeah/coffee-script
hbt/coffee-script
helixbass/copheescript
hleumas/coffee-script
holmsand/coffee-script
holtwick/moccacino
hugs/coffee-script
ich/caffeine
jaekwon/coffee-script
jameskyokushin/coffee-script
janlelis/angular-coffee-script
jasonknight/coffee-script
jasonyandell/coffee-script
jawj/coffee-script
jiangmiao/toffeescript
joelturnbull/coffee-script
johnsang/coffee-script
joliss/coffee-script
jstrachan/coffee-script
jugglinmike/irene-script
juil/coffee-script
keichii/coffee-script
keithnorm/coffee-script
kengregson/coffee-script
kewinwang/coffee-script
khaled/coffee-script
kiddphunk/coffee-script
leobm/coffee-script
lfendy/coffee-script
loganfsmyth/coffee-script
loopinfinito/coffeescript.com.br
lorensr/coffee-script
loveencounterflow/coffy-script
lukhnos/doubleshot
lynaghk/coffee-script
manlon/coffee-script
martco/coffee-script
maxtaco/coffee-script
mblinn/coffee-script
mehmeta/coffee-script
mgutz/coffee-script
michaelficarra/coffee-script
misfo/coffee-script
mizchi/coffee-script
mlinderm/coffee-script
mrlauer/coffee-script-monads
muratmeran/coffee-script
neobine/coffee-script
netconstructor/coffee-script
nhemsley/contracts.coffee
niedfelj/coffee-script
oglu/coffee-script
onilabs/coffee-script
ozzie00/coffee-script
paiq/blackcoffee
parkerl/coffee-script
paulmars/coffee-script
peick/coffee-script
phiggins/coffee-script
pjaspers/coffee-script
poutyface/coffee-script
pschyska/coffee-script
ptoomey3/coffee-script
quangv/coffee-script
rand6/coffee-script
ress/coffee-script
revence27/coffee-script
rkJun/coffee-script
robarondaz/coffee-script
robb-broome/coffee-script
rolftimmermans/coffee-script
rpl/coffee-script
runeb/coffee-script
rwaldron/coffee-script
rymohr/coffee-script
samcday/coffee-script
sarang25491/coffee-script
satyr/coffee-script
seanjensengrey/coffee-script
sebzim4500/coffee-script
seedjs/coffee-script
serdary/coffee-script
shariefsk/coffee-script
shesek/coffee-script
shimaore/cake
shlevy/coffee-script
siefkenj/gjscoffee-script
smhanov/coffee-script
softprops/coffee-script
soutaro/coffee-script
spaghetticode/coffee-script
stephank/coffee-script
stepheneb/coffee-script
swistak/coffee-script
syg/heap.coffee
taku0/coffee-script
tanob/coffee-script
tglines/coffee-script
thdtjsdn/coffee-script
theIntuitionist/coffee-script
thedeeno/coffee-script
thejh/coffee-script
tlrobinson/coffee-script
tomelam/coffee-script
tosh/coffee-script
tswicegood/coffee-script
ttilley/coffee-script
up2u0609/coffee-script
vanviegen/coffee-script
vjpr/coffee-script
vol4ok/coffee-script
walski/coffee-script
wearefractal/yerbascript
willmoffat/coffee-script
wjdix/coffee-script
xingyunshisui/coffee-script
xixixao/coffee-script
yihuang/coffee-script
zaach/coffee-script
zmthy/coffee-script
zot/coffee-script
Nothing to show
base: 0.3.0
head repository: jashkenas/coffeescript
Choose a Head Repository
jashkenas/coffeescript
CDR2003/coffee-script-lua
CircleCode/coffee-script
Crylock/coffee-script
GeoffreyBooth/coffeescript
Gregg/coffee-script
JamesTryand/coffee-script
JustinTulloss/coffee-script
LittleForker/coffee-script
MichaelBlume/coffee-script
NightMigera/coffeescript
ProximaMonkey/coffee-script
SE7ENSKY/matescript
STRd6/coffee-script
StanAngeloff/coffee-script
Thorsson/coffee-script
TobiaszCudnik/coffeescript-to-typescript
Xavura/coffee-script
Xepo/coffee-script
agnoster/coffee-script
akiellor/coffee-script
alanning/coffee-script
allanberger/coffee-script
almost/coffee-script
alubbe/coffee-script
andrewschaaf/coffee-script
andreypopp/coffee-script
anibal/coffee-script
apanda/coffee-script
baoshitang/coffee-script
barberboy/coffee-script
benbria/coffee-script
benekastah/coffee-script
bhuga/coffee-script
bjouhier/coffee-script
blahutka/coffee-script
blossom/coffee-script
bolinfest/coffee-script
breckinloggins/coffee-script
bsparrow435/coffee-script
burrows/coffee-script
capndesign/coffee-script
catharinejm/coffee-script
charles-cai/coffee-script
charliesome/coffee-script
chetan51/coffee-script
chip/coffee-script
codelahoma/coffee-script
coffee-js/coffee-script
coffee-void/coffeescript
collin/coffee-script
contra/yerbascript
danemorgridge/coffee-script
daveclarke/coffee-script
daveyoon/coffee-script
devongovett/coffee-script
dget/coffee-script
disnet/contracts.coffee
dmohl/coffee-script
dohse/coffee-script
dougnukem/coffee-script
dpritchett/coffee-script
dqminh/coffee-script
drewlesueur/coffee-script
dylanetkin/coffee-script
ef4/coffee-script
emmalemma/coffee-script
evilpie/coffee-script
excellentdrums/coffee-script
fauzias/coffee-script
fitzgen/coffee-script
fizx/coffee-script
franc/coffee-script
frontflip/coffee-script
geraldalewis/coffee-script
germanocaldeira/coffee-script
gfodor/coffee-script
ghuntley/coffee-script
goodwink/coffee-script
hayeah/coffee-script
hbt/coffee-script
helixbass/copheescript
hleumas/coffee-script
holmsand/coffee-script
holtwick/moccacino
hugs/coffee-script
ich/caffeine
jaekwon/coffee-script
jameskyokushin/coffee-script
janlelis/angular-coffee-script
jasonknight/coffee-script
jasonyandell/coffee-script
jawj/coffee-script
jiangmiao/toffeescript
joelturnbull/coffee-script
johnsang/coffee-script
joliss/coffee-script
jstrachan/coffee-script
jugglinmike/irene-script
juil/coffee-script
keichii/coffee-script
keithnorm/coffee-script
kengregson/coffee-script
kewinwang/coffee-script
khaled/coffee-script
kiddphunk/coffee-script
leobm/coffee-script
lfendy/coffee-script
loganfsmyth/coffee-script
loopinfinito/coffeescript.com.br
lorensr/coffee-script
loveencounterflow/coffy-script
lukhnos/doubleshot
lynaghk/coffee-script
manlon/coffee-script
martco/coffee-script
maxtaco/coffee-script
mblinn/coffee-script
mehmeta/coffee-script
mgutz/coffee-script
michaelficarra/coffee-script
misfo/coffee-script
mizchi/coffee-script
mlinderm/coffee-script
mrlauer/coffee-script-monads
muratmeran/coffee-script
neobine/coffee-script
netconstructor/coffee-script
nhemsley/contracts.coffee
niedfelj/coffee-script
oglu/coffee-script
onilabs/coffee-script
ozzie00/coffee-script
paiq/blackcoffee
parkerl/coffee-script
paulmars/coffee-script
peick/coffee-script
phiggins/coffee-script
pjaspers/coffee-script
poutyface/coffee-script
pschyska/coffee-script
ptoomey3/coffee-script
quangv/coffee-script
rand6/coffee-script
ress/coffee-script
revence27/coffee-script
rkJun/coffee-script
robarondaz/coffee-script
robb-broome/coffee-script
rolftimmermans/coffee-script
rpl/coffee-script
runeb/coffee-script
rwaldron/coffee-script
rymohr/coffee-script
samcday/coffee-script
sarang25491/coffee-script
satyr/coffee-script
seanjensengrey/coffee-script
sebzim4500/coffee-script
seedjs/coffee-script
serdary/coffee-script
shariefsk/coffee-script
shesek/coffee-script
shimaore/cake
shlevy/coffee-script
siefkenj/gjscoffee-script
smhanov/coffee-script
softprops/coffee-script
soutaro/coffee-script
spaghetticode/coffee-script
stephank/coffee-script
stepheneb/coffee-script
swistak/coffee-script
syg/heap.coffee
taku0/coffee-script
tanob/coffee-script
tglines/coffee-script
thdtjsdn/coffee-script
theIntuitionist/coffee-script
thedeeno/coffee-script
thejh/coffee-script
tlrobinson/coffee-script
tomelam/coffee-script
tosh/coffee-script
tswicegood/coffee-script
ttilley/coffee-script
up2u0609/coffee-script
vanviegen/coffee-script
vjpr/coffee-script
vol4ok/coffee-script
walski/coffee-script
wearefractal/yerbascript
willmoffat/coffee-script
wjdix/coffee-script
xingyunshisui/coffee-script
xixixao/coffee-script
yihuang/coffee-script
zaach/coffee-script
zmthy/coffee-script
zot/coffee-script
Nothing to show
compare: 0.3.2
2 contributors
Commits on Jan 27, 2010
Commits on Jan 30, 2010
Commits on Jan 31, 2010
Commits on Feb 01, 2010
Commits on Feb 02, 2010
Commits on Feb 03, 2010
Commits on Feb 04, 2010
Commits on Feb 06, 2010
Commits on Feb 07, 2010
…he node branch without breaking narwhal compatibility
…e narwhal instead. All tests are executing successfully against both Node.js and Narwhal/Rhino backends
Commits on Feb 08, 2010
Showing with 4,873 additions and 1,467 deletions.
  1. +7 −3 Rakefile
  2. +2 −2 coffee-script.gemspec
  3. +2 −0 documentation/coffee/aliases.coffee
  4. +3 −3 documentation/coffee/fat_arrow.coffee
  5. +3 −3 documentation/coffee/super.coffee
  6. +31 −12 documentation/index.html.erb
  7. +1 −0 documentation/js/aliases.js
  8. +1 −1 documentation/js/existence.js
  9. +3 −3 examples/beautiful_code/binary_search.coffee
  10. +3 −3 examples/beautiful_code/quicksort_runtime.coffee
  11. +6 −6 examples/beautiful_code/regular_expression_matcher.coffee
  12. +57 −0 examples/blocks.coffee
  13. +4 −4 examples/computer_science/binary_search.coffee
  14. +2 −2 examples/computer_science/bubble_sort.coffee
  15. +10 −10 examples/computer_science/linked_list.coffee
  16. +3 −3 examples/computer_science/luhn_algorithm.coffee
  17. +2 −2 examples/computer_science/merge_sort.coffee
  18. +3 −3 examples/computer_science/selection_sort.coffee
  19. +6 −0 extras/CoffeeScript.tmbundle/Syntaxes/CoffeeScript.tmLanguage
  20. +42 −20 index.html
  21. +1 −1 lib/coffee-script.rb
  22. +50 −0 lib/coffee_script/coffee-script.js
  23. +17 −11 lib/coffee_script/command_line.rb
  24. +11 −9 lib/coffee_script/grammar.y
  25. +363 −0 lib/coffee_script/lexer.js
  26. +2 −4 lib/coffee_script/lexer.rb
  27. +21 −5 lib/coffee_script/narwhal/{lib → }/coffee-script.js
  28. +0 −21 lib/coffee_script/narwhal/lib/coffee-script/loader.js
  29. +0 −19 lib/coffee_script/narwhal/loader.coffee
  30. +443 −0 lib/coffee_script/nodes.js
  31. +24 −9 lib/coffee_script/nodes.rb
  32. +477 −0 lib/coffee_script/parser.js
  33. +1,222 −1,140 lib/coffee_script/parser.rb
  34. +33 −0 lib/coffee_script/repl.js
  35. +377 −0 lib/coffee_script/rewriter.js
  36. +26 −26 lib/coffee_script/rewriter.rb
  37. +11 −0 lib/coffee_script/runner.js
  38. +73 −0 lib/coffee_script/scope.js
  39. +2 −3 package.json
  40. +45 −0 src/coffee-script.coffee
  41. +280 −0 src/lexer.coffee
  42. +36 −21 {lib/coffee_script → src}/narwhal/coffee-script.coffee
  43. +214 −0 src/nodes.coffee
  44. +468 −0 src/parser.coffee
  45. +26 −0 src/repl.coffee
  46. +244 −0 src/rewriter.coffee
  47. +12 −0 src/runner.coffee
  48. +49 −0 src/scope.coffee
  49. +10 −5 test/fixtures/execution/test_arguments.coffee
  50. +14 −8 test/fixtures/execution/test_array_comprehension.coffee
  51. +3 −3 test/fixtures/execution/test_assignment.coffee
  52. +1 −1 test/fixtures/execution/test_blocks.coffee
  53. +4 −4 test/fixtures/execution/test_calling_super.coffee
  54. +3 −3 test/fixtures/execution/test_chained_calls.coffee
  55. +11 −11 test/fixtures/execution/test_destructuring_assignment.coffee
  56. +1 −1 test/fixtures/execution/test_everything.coffee
  57. +14 −12 test/fixtures/execution/test_existence.coffee
  58. +3 −3 test/fixtures/execution/test_expressions.coffee
  59. +3 −3 test/fixtures/execution/test_fancy_if_statement.coffee
  60. +18 −17 test/fixtures/execution/test_functions.coffee
  61. +1 −1 test/fixtures/execution/test_funky_comments.coffee
  62. +6 −6 test/fixtures/execution/test_heredocs.coffee
  63. +2 −2 test/fixtures/execution/test_lexical_scope.coffee
  64. +18 −7 test/fixtures/execution/test_literals.coffee
  65. +3 −3 test/fixtures/execution/test_nested_comprehensions.coffee
  66. +1 −1 test/fixtures/execution/test_newline_escaping.coffee
  67. +5 −5 test/fixtures/execution/test_operations.coffee
  68. +3 −3 test/fixtures/execution/test_range_comprehension.coffee
  69. +7 −2 test/fixtures/execution/test_ranges_and_slices.coffee
  70. +5 −5 test/fixtures/execution/test_splats.coffee
  71. +1 −1 test/fixtures/execution/test_splices.coffee
  72. +5 −5 test/fixtures/execution/test_switch.coffee
  73. +3 −3 test/fixtures/execution/test_while.coffee
  74. +3 −3 test/fixtures/generation/statements_as_expressions.coffee
  75. +7 −0 test/unit/test_execution.rb
@@ -17,10 +17,14 @@ namespace :build do
sh "racc #{args[:racc_args]} -o lib/coffee_script/parser.rb lib/coffee_script/grammar.y"
end

desc "Compile the Narwhal interface for --interactive and --run"
desc "Compile the Narwhal interface"
task :narwhal do
sh "bin/coffee lib/coffee_script/narwhal/*.coffee -o lib/coffee_script/narwhal/lib/coffee-script"
sh "mv lib/coffee_script/narwhal/lib/coffee-script/coffee-script.js lib/coffee_script/narwhal/lib/coffee-script.js"
sh "bin/coffee src/narwhal/*.coffee -o lib/coffee_script/narwhal"
end

desc "Continually compile the CoffeeScript/Node.js components with --watch"
task :node do
sh "bin/coffee -w src/*.coffee -o lib/coffee_script/"
end

desc "Compile and install the Ultraviolet syntax highlighter"
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'coffee-script'
s.version = '0.3.0' # Keep version in sync with coffee-script.rb
s.date = '2010-1-26'
s.version = '0.3.2' # Keep version in sync with coffee-script.rb
s.date = '2010-2-8'

s.homepage = "http://jashkenas.github.com/coffee-script/"
s.summary = "The CoffeeScript Compiler"
@@ -5,3 +5,5 @@ volume: 10 if band isnt spinal_tap
let_the_wild_rumpus_begin() unless answer is no

if car.speed < speed_limit then accelerate()

print "My name is " + @name
@@ -1,6 +1,6 @@
Account: (customer, cart) ->
this.customer: customer
this.cart: cart
@customer: customer
@cart: cart

$('.shopping_cart').bind 'click', (event) =>
this.customer.purchase this.cart
@customer.purchase @cart
@@ -1,14 +1,14 @@
Animal: ->
Animal::move: (meters) ->
alert this.name + " moved " + meters + "m."
alert @name + " moved " + meters + "m."

Snake: (name) -> this.name: name
Snake: (name) -> @name: name
Snake extends Animal
Snake::move: ->
alert "Slithering..."
super 5

Horse: (name) -> this.name: name
Horse: (name) -> @name: name
Horse extends Animal
Horse::move: ->
alert "Galloping..."
@@ -51,7 +51,7 @@

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

<h2>Table of Contents</h2>
@@ -118,7 +118,7 @@ gem install coffee-script</pre>
Installing the gem provides the <tt>coffee</tt> command, which can
be used to compile CoffeeScript <tt>.coffee</tt> files into JavaScript, as
well as debug them. In conjunction with
<a href="http://narwhaljs.org/">Narwhal</a>, the <tt>coffee</tt>
<a href="http://nodejs.org/">Node.js</a> (or <a href="http://narwhaljs.org/">Narwhal</a>), the <tt>coffee</tt>
command also provides direct evaluation and an interactive REPL.
When compiling to JavaScript, <tt>coffee</tt> writes the output
as <tt>.js</tt> files in the same directory by default, but output
@@ -130,14 +130,16 @@ gem install coffee-script</pre>
<td width="25%"><code>-i, --interactive</code></td>
<td>
Launch an interactive CoffeeScript session.
Requires <a href="http://narwhaljs.org/">Narwhal</a>.
Requires <a href="http://nodejs.org/">Node.js</a>,
or <a href="http://narwhaljs.org/">Narwhal</a>, with <tt>--narwhal</tt>.
</td>
</tr>
<tr>
<td><code>-r, --run</code></td>
<td>
Compile and execute scripts without saving the intermediate
JavaScript. Requires <a href="http://narwhaljs.org/">Narwhal</a>.
JavaScript. Requires <a href="http://nodejs.org/">Node.js</a>,
or <a href="http://narwhaljs.org/">Narwhal</a>, with <tt>--narwhal</tt>.
</td>
</tr>
<tr>
@@ -194,7 +196,7 @@ gem install coffee-script</pre>
<td><code>-n, --no-wrap</code></td>
<td>
Compile the JavaScript without the top-level function safety wrapper.
(Used for CoffeeScript as a Narwhal module.)
(Used for CoffeeScript as a Node.js module.)
</td>
</tr>
<tr>
@@ -367,6 +369,9 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<p>
For single-line statements, <tt>unless</tt> can be used as the inverse of <tt>if</tt>.
</p>
<p>
As a shortcut for <tt>this.property</tt>, you can use <tt>@property</tt>.
</p>
<%= code_for('aliases') %>

<p id="splats">
@@ -624,21 +629,22 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<ul>
<li>
<a href="http://github.com/jashkenas/coffee-script/">Source Code</a><br />
After checking out the source, make sure to run <tt>rake build:parser</tt>
to generate an up-to-date version of the Racc parser.
Use <tt>bin/coffee</tt> to test your changes,
<tt>rake test</tt> to run the test suite,
<tt>rake build:parser</tt> to regenerate the Racc parser if you're
working on the grammar,
and <tt>rake gem:install</tt> to
create and install a custom version of the gem.
</li>
<li>
<a href="http://github.com/jashkenas/coffee-script/issues">Bugs, Feature Requests, and General Discussion</a>
<a href="http://github.com/jashkenas/coffee-script/issues">CoffeeScript Issues</a><br />
Bugs reports, feature requests, and general discussion all belong here.
</li>
<li>
<a href="http://github.com/creationix/coffeepot">CoffeePot</a><br />
An implementation of CoffeeScript, written in CoffeeScript, by
<a href="http://github.com/creationix">Tim Caswell</a>. Compiles just
a limited subset at this point.
<a href="http://github.com/mattly/rack-coffee">rack-coffee</a><br />
Rack middleware for serving CoffeeScripts as JavaScript directly to
the browser, without having to compile them first. From
<a href="http://github.com/mattly">Matt Lyon</a>.
</li>
<li>
<a href="http://github.com/jnicklas/bistro_car">BistroCar</a><br />
@@ -653,9 +659,22 @@ coffee --print app/scripts/*.coffee > concatenation.js</pre>
<a href="http://github.com/inem">Ivan Nemytchenko</a>, that embeds
snippets of CoffeeScript within your HAML templates.
</li>
<li>
<a href="http://github.com/creationix/coffeepot">CoffeePot</a><br />
An implementation of CoffeeScript, written in CoffeeScript, by
<a href="http://github.com/creationix">Tim Caswell</a>. Compiles just
a limited subset at this point.
</li>
</ul>

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

<p>
<b class="header" style="margin-top: 20px;">0.3.2</b>
<tt>@property</tt> is now a shorthand for <tt>this.property</tt>.<br />
Switched the default JavaScript engine from Narwhal to Node.js. Pass
the <tt>--narwhal</tt> flag if you'd like to continue using it.
</p>

<p>
<b class="header" style="margin-top: 20px;">0.3.0</b>
@@ -10,4 +10,5 @@
let_the_wild_rumpus_begin();
}
car.speed < speed_limit ? accelerate() : null;
print("My name is " + this.name);
})();
@@ -1,6 +1,6 @@
(function(){
var solipsism, speed;
if ((typeof mind !== "undefined" && mind !== null) && !(typeof world !== "undefined" && world !== null)) {
if ((typeof mind !== "undefined" && mind !== null) && (typeof !world !== "undefined" && !world !== null)) {
solipsism = true;
}
speed = (typeof speed !== "undefined" && speed !== null) ? speed : 140;
@@ -11,6 +11,6 @@ index: (list, target) ->
if val < target then low: mid + 1 else high: mid
return -1

print(2 is index([10, 20, 30, 40, 50], 30))
print(4 is index([-97, 35, 67, 88, 1200], 1200))
print(0 is index([0, 45, 70], 0))
puts 2 is index([10, 20, 30, 40, 50], 30)
puts 4 is index([-97, 35, 67, 88, 1200], 1200)
puts 0 is index([0, 45, 70], 0)
@@ -8,6 +8,6 @@ runtime: (N) ->
t: n - 1 + sum / n
t

print(runtime(3) is 2.6666666666666665)
print(runtime(5) is 7.4)
print(runtime(8) is 16.92142857142857)
puts runtime(3) is 2.6666666666666665
puts runtime(5) is 7.4
puts runtime(8) is 16.92142857142857
@@ -26,9 +26,9 @@ match_star: (c, regexp, text) ->
return false unless text and (text[0] is c or c is '.')
text: text.slice(1)

print(match("ex", "some text"))
print(match("s..t", "spit"))
print(match("^..t", "buttercup"))
print(match("i..$", "cherries"))
print(match("o*m", "vrooooommm!"))
print(match("^hel*o$", "hellllllo"))
puts match("ex", "some text")
puts match("s..t", "spit")
puts match("^..t", "buttercup")
puts match("i..$", "cherries")
puts match("o*m", "vrooooommm!")
puts match("^hel*o$", "hellllllo")
@@ -0,0 +1,57 @@
# After wycats' http://yehudakatz.com/2010/02/07/the-building-blocks-of-ruby/

# Sinatra.
get '/hello', ->
'Hello World'


# Append.
append: (location, data) ->
path: new Pathname location
throw "Location does not exist" unless path.exists()

File.open path, 'a', (file) ->
file.puts YAML.dump data

data


# Rubinius' File.open implementation.
File.open: (path, mode, block) ->
io: new File path, mode

return io unless block

try
block io
finally
try
io.close() unless io.closed()
catch error
# nothing, just swallow them.


# Write.
write: (location, data) ->
path = new Pathname location
raise "Location does not exist" unless path.exists()

File.open path, 'w', (file) ->
return false if Digest.MD5.hexdigest(file.read()) is data.hash()
file.puts YAML.dump data
true


# Rails' respond_to.
index: ->
people: Person.find 'all'

respond_to (format) ->
format.html()
format.xml -> render { xml: people.xml() }


# Synchronization.
synchronize: (block) ->
lock()
try block() finally unlock()
@@ -19,7 +19,7 @@ binary_search: (items, value) ->


# Test the function.
print(2 is binary_search([10, 20, 30, 40, 50], 30))
print(4 is binary_search([-97, 35, 67, 88, 1200], 1200))
print(0 is binary_search([0, 45, 70], 0))
print(-1 is binary_search([0, 45, 70], 10))
puts(2 is binary_search([10, 20, 30, 40, 50], 30))
puts(4 is binary_search([-97, 35, 67, 88, 1200], 1200))
puts(0 is binary_search([0, 45, 70], 0))
puts(-1 is binary_search([0, 45, 70], 10))
@@ -7,5 +7,5 @@ bubble_sort: (list) ->


# Test the function.
print(bubble_sort([3, 2, 1]).join(' ') is '1 2 3')
print(bubble_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
puts(bubble_sort([3, 2, 1]).join(' ') is '1 2 3')
puts(bubble_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
@@ -91,16 +91,16 @@ LinkedList::toString: -> this.toArray().toString()
list: new LinkedList()

list.add("Hi")
print(list.size() is 1)
print(list.item(0) is "Hi")
print(list.item(1) is null)
puts(list.size() is 1)
puts(list.item(0) is "Hi")
puts(list.item(1) is null)

list: new LinkedList()
list.add("zero").add("one").add("two")
print(list.size() is 3)
print(list.item(2) is "two")
print(list.remove(1) is "one")
print(list.item(0) is "zero")
print(list.item(1) is "two")
print(list.size() is 2)
print(list.item(-10) is null)
puts(list.size() is 3)
puts(list.item(2) is "two")
puts(list.remove(1) is "one")
puts(list.item(0) is "zero")
puts(list.item(1) is "two")
puts(list.size() is 2)
puts(list.item(-10) is null)
@@ -31,6 +31,6 @@ is_valid_identifier: (identifier) ->


# Tests.
print(is_valid_identifier("49927398716") is true)
print(is_valid_identifier("4408041234567893") is true)
print(is_valid_identifier("4408041234567890") is false)
puts(is_valid_identifier("49927398716") is true)
puts(is_valid_identifier("4408041234567893") is true)
puts(is_valid_identifier("4408041234567890") is false)
@@ -15,5 +15,5 @@ merge_sort: (list) ->


# Test the function.
print(merge_sort([3, 2, 1]).join(' ') is '1 2 3')
print(merge_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
puts(merge_sort([3, 2, 1]).join(' ') is '1 2 3')
puts(merge_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
@@ -9,7 +9,7 @@ selection_sort: (list) ->
min: i

# Check the rest of the array to see if anything is smaller.
(min: j if list[j] < list[min]) for j in [i+1...len]
(min: j if list[j] < list[min]) for j in [(i+1)...len]

# Swap if a smaller item has been found.
[list[i], list[min]]: [list[min], list[i]] if i isnt min
@@ -19,5 +19,5 @@ selection_sort: (list) ->


# Test the function.
print(selection_sort([3, 2, 1]).join(' ') is '1 2 3')
print(selection_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
puts(selection_sort([3, 2, 1]).join(' ') is '1 2 3')
puts(selection_sort([9, 2, 7, 0, 1]).join(' ') is '0 1 2 7 9')
@@ -72,6 +72,12 @@
<key>name</key>
<string>constant.numeric.coffee</string>
</dict>
<dict>
<key>match</key>
<string>(@)[a-zA-Z_$]\w*</string>
<key>name</key>
<string>variable.other.readwrite.instance.coffee</string>
</dict>
<dict>
<key>name</key>
<string>string.quoted.heredoc.coffee</string>

Showing you all comments on commits in this comparison.

This comment has been minimized.

Copy link

creationix commented on cb7a103 Feb 3, 2010

So weepy finally convinced you this is a good idea then? :P

This comment has been minimized.

Copy link
Owner Author

jashkenas commented on cb7a103 Feb 3, 2010

I still don't like the syntax, but it seems much-beloved by most.

This comment has been minimized.

Copy link
Contributor

mattly commented on cb7a103 Feb 3, 2010

people: use this for good, not evil.

This comment has been minimized.

Copy link
Contributor

olsonjeffery commented on cb7a103 Feb 3, 2010

creeping rubyism

This comment has been minimized.

Copy link
Contributor

StanAngeloff commented on cb7a103 Feb 3, 2010

@var doesn't work well when you assign to it:

Animal: (name) ->
    @name: name

horse: new Animal('Bob')

produces:

var Animal, horse;
Animal = function Animal(name) {
  var __a, this.name;
  __a = this.name = name;
  return Animal === this.constructor ? this : __a;
};
horse = new Animal('Bob');

Still a good start!

This comment has been minimized.

Copy link
Owner Author

jashkenas commented on cb7a103 Feb 3, 2010

Thanks for the bug report, Stan. This is now fixed on both node and master. The ValueNode didn't realize that a ThisNode counts the same as having properties -- I've straightened it out.