Comparing changes
Open a pull request
|
|
jashkenas |
Fixing (at least partially) Issue #502. Trailing block comment parse.
|
4eed514
|
|||
|
|
jashkenas |
fixing existential chains directly against a 'new Func()' call. Issue #…
|
2a93259
|
|
|
jashkenas |
adding a new comprehension 'for all key, value of object', which comp…
…iles to the naked JS for..in, including enumerable properties inherited from prototypes. |
72c4efb
|
|||
|
|
jashkenas |
Fixing Issue #506. existential chains should force parentheses in the…
… presense of a compiled ternary operator. |
b810d10
|
|
|
jashkenas |
michaelficarra's suggestion to make object comprehensions' hasOwnProp…
…erty check a continue, instead of a wrapped if. |
6c8eab7
|
|||
|
|
jashkenas |
updating docco to better reflect lack of explicit ternaries. Issue #510
|
ec2d358
|
|||
|
|
jashkenas |
Updating documentation with endtime's suggestions.
|
9814fc2
|
|||
|
|
jashkenas |
renamed #strings sectiong to #heredocs
|
a322b3a
|
|||
|
|
jashkenas |
Reserving __hasProp and friends, for safety's sake.
|
96f0769
|
|||
|
|
jashkenas |
enhancements to range comprehensions, back to being safe -- and usabl…
…e downwards without a 'by' clause, and optimized when working with integer literals. |
5a34f53
|
|
|
jashkenas |
Moving from '.addListener' to '.on' for Node v0.1.101
|
d017a8f
|
|||
|
|
jashkenas |
adding no-argument super calls.
|
989d539
|
|||
|
|
sstephenson |
`class B extends A` calls `A.extended(B)`
|
5678bf1
|
|
|
jashkenas |
updating documentation with correct variable names.
|
0a3f6c4
|
|||
|
|
jashkenas |
updating package.json to work better with NPM. Issue #522
|
24a5adc
|
|
|
jashkenas |
removing the last traces of half-assignments. Issue #541.
|
b18d7fb
|
|||
|
|
jashkenas |
better output when trying to force a pure statment to become a return
|
d1b17df
|
|||
|
|
jashkenas |
tiny thing.
|
af451bc
|
|
|
jashkenas |
using double-quotes for auto-quoted object keys and hash accesses. JS…
…ON-style. Issue #556 |
ebad1ec
|
|||
|
|
jashkenas |
Issue #559, renaming {source} option to {fileName}, on CoffeeScript.c…
…ompile |
071b527
|
|||
|
|
jashkenas |
Fixing Issue #552, Indentation bug with chained calls with nested obj…
…ect literals... |
f3caa92
|
|||
|
|
jashkenas |
Fixing issue #544. Needed to special case implicit-object-closing for…
… outdents -- it's different than a single-line implicit object with a terminator. |
acd69b1
|
|||
|
|
jashkenas |
Fixing Issue #509. Double-evaluation for function calls within IndexN…
…odes as the left-hand-assignment part of a compound-assignment operation. |
8b953bb
|
|||
|
|
jashkenas |
fixing up compout assignment for ?=, which was using a sligtly differ…
…ent path. |
d4ac11c
|
|||
|
|
jashkenas |
git-go
|
3301738
|
|
|
jashkenas |
regenerating large swathes of the docs
|
b42045f
|
|||
|
|
jashkenas |
more additions to the documentation for 0.9.0
|
f43c79c
|
|
|
brodyberg |
Fix typo
|
4d2dd33
|
- +44 −43 Cakefile
- +2 −2 Rakefile
- +3 −3 documentation/coffee/aliases.coffee
- +1 −1 documentation/coffee/array_comprehensions.coffee
- +0 −2 documentation/coffee/assignment.coffee
- +4 −0 documentation/coffee/block_comment.coffee
- +9 −3 documentation/coffee/cake_tasks.coffee
- +4 −8 documentation/coffee/classes.coffee
- +2 −2 documentation/coffee/comparisons.coffee
- +5 −3 documentation/coffee/conditionals.coffee
- +1 −1 documentation/coffee/embedded.coffee
- +1 −1 documentation/coffee/existence.coffee
- +2 −2 documentation/coffee/expressions.coffee
- +1 −1 documentation/coffee/expressions_assignment.coffee
- +1 −1 documentation/coffee/expressions_comprehension.coffee
- +3 −3 documentation/coffee/fat_arrow.coffee
- +2 −2 documentation/coffee/functions.coffee
- +5 −5 documentation/coffee/heredocs.coffee
- +2 −2 documentation/coffee/interpolation.coffee
- +3 −3 documentation/coffee/interpolation_expression.coffee
- +2 −2 documentation/coffee/multiple_return_values.coffee
- +2 −2 documentation/coffee/object_comprehensions.coffee
- +3 −5 documentation/coffee/object_extraction.coffee
- +12 −8 documentation/coffee/objects_and_arrays.coffee
- +1 −1 documentation/coffee/objects_reserved.coffee
- +8 −9 documentation/coffee/overview.coffee
- +3 −3 documentation/coffee/parallel_assignment.coffee
- +2 −2 documentation/coffee/patterns_and_splats.coffee
- +2 −2 documentation/coffee/prototypes.coffee
- +4 −4 documentation/coffee/range_comprehensions.coffee
- +5 −5 documentation/coffee/scope.coffee
- +3 −3 documentation/coffee/slices.coffee
- +6 −6 documentation/coffee/splats.coffee
- +2 −2 documentation/coffee/splices.coffee
- +1 −1 documentation/coffee/strings.coffee
- +2 −2 documentation/coffee/while.coffee
- +13 −7 documentation/css/docs.css
- +28 −30 documentation/docs/cake.html
- +27 −28 documentation/docs/coffee-script.html
- +64 −62 documentation/docs/command.html
- +121 −105 documentation/docs/grammar.html
- +25 −23 documentation/docs/helpers.html
- +1 −1 documentation/docs/index.html
- +233 −225 documentation/docs/lexer.html
- +860 −806 documentation/docs/nodes.html
- +39 −39 documentation/docs/optparse.html
- +10 −12 documentation/docs/repl.html
- +141 −98 documentation/docs/rewriter.html
- +25 −25 documentation/docs/scope.html
- +150 −150 documentation/docs/underscore.html
- +104 −82 documentation/index.html.erb
- +15 −17 documentation/js/aliases.js
- +19 −21 documentation/js/array_comprehensions.js
- +0 −5 documentation/js/assignment.js
- +4 −0 documentation/js/block_comment.js
- +10 −15 documentation/js/cake_tasks.js
- +32 −35 documentation/js/classes.js
- +3 −5 documentation/js/comparisons.js
- +12 −12 documentation/js/conditionals.js
- +3 −5 documentation/js/embedded.js
- +5 −7 documentation/js/existence.js
- +11 −17 documentation/js/expressions.js
- +2 −4 documentation/js/expressions_assignment.js
- +11 −11 documentation/js/expressions_comprehension.js
- +7 −9 documentation/js/expressions_try.js
- +10 −14 documentation/js/fat_arrow.js
- +7 −9 documentation/js/functions.js
- +2 −4 documentation/js/heredocs.js
- +3 −5 documentation/js/interpolation.js
- +4 −6 documentation/js/interpolation_expression.js
- +0 −7 documentation/js/intro.js
- +8 −10 documentation/js/multiple_return_values.js
- +16 −17 documentation/js/object_comprehensions.js
- +15 −17 documentation/js/object_extraction.js
- +17 −10 documentation/js/objects_and_arrays.js
- +3 −5 documentation/js/objects_reserved.js
- +32 −35 documentation/js/overview.js
- +6 −8 documentation/js/parallel_assignment.js
- +7 −9 documentation/js/patterns_and_splats.js
- +3 −5 documentation/js/prototypes.js
- +0 −8 documentation/js/punctuation.js
- +18 −21 documentation/js/range_comprehensions.js
- +8 −11 documentation/js/scope.js
- +4 −6 documentation/js/slices.js
- +2 −4 documentation/js/soaks.js
- +15 −18 documentation/js/splats.js
- +3 −5 documentation/js/splices.js
- +3 −5 documentation/js/strings.js
- +15 −17 documentation/js/switch.js
- +8 −10 documentation/js/try.js
- +16 −18 documentation/js/while.js
- +8 −8 examples/beautiful_code/binary_search.coffee
- +3 −3 examples/beautiful_code/quicksort_runtime.coffee
- +6 −6 examples/beautiful_code/regular_expression_matcher.coffee
- +11 −14 examples/blocks.coffee
- +39 −45 examples/code.coffee
- +11 −11 examples/computer_science/binary_search.coffee
- +4 −4 examples/computer_science/bubble_sort.coffee
- +32 −32 examples/computer_science/linked_list.coffee
- +9 −9 examples/computer_science/luhn_algorithm.coffee
- +7 −7 examples/computer_science/merge_sort.coffee
- +7 −7 examples/computer_science/selection_sort.coffee
- +40 −45 examples/poignant.coffee
- +39 −38 examples/potion.coffee
- +169 −169 examples/underscore.coffee
- +4 −4 examples/web_server.coffee
- +2 −2 extras/coffee-script.js
- +362 −357 index.html
- +7 −9 lib/cake.js
- +6 −7 lib/coffee-script.js
- +12 −9 lib/command.js
- +54 −17 lib/grammar.js
- +13 −9 lib/helpers.js
- +4 −3 lib/index.js
- +69 −63 lib/lexer.js
- +377 −233 lib/nodes.js
- +2 −2 lib/optparse.js
- +210 −176 lib/parser.js
- +5 −5 lib/repl.js
- +261 −242 lib/rewriter.js
- +13 −12 lib/scope.js
- +5 −4 package.json
- +26 −27 src/cake.coffee
- +26 −27 src/coffee-script.coffee
- +66 −64 src/command.coffee
- +57 −40 src/grammar.coffee
- +27 −22 src/helpers.coffee
- +1 −1 src/index.coffee
- +205 −203 src/lexer.coffee
- +627 −560 src/nodes.coffee
- +35 −35 src/optparse.coffee
- +12 −14 src/repl.coffee
- +134 −86 src/rewriter.coffee
- +14 −14 src/scope.coffee
- +25 −7 test/test_arguments.coffee
- +7 −7 test/test_assignment.coffee
- +26 −6 test/test_blocks.coffee
- +6 −6 test/test_break.coffee
- +7 −7 test/test_chaining.coffee
- +104 −33 test/test_classes.coffee
- +28 −18 test/test_comments.coffee
- +5 −5 test/test_compilation.coffee
- +14 −14 test/test_compound_assignment.coffee
- +52 −32 test/test_comprehensions.coffee
- +31 −16 test/test_existence.coffee
- +4 −4 test/test_expressions.coffee
- +79 −44 test/test_functions.coffee
- +29 −29 test/test_heredocs.coffee
- +25 −12 test/test_if.coffee
- +98 −29 test/test_literals.coffee
- +2 −2 test/test_module.coffee
- +43 −14 test/test_operations.coffee
- +4 −4 test/test_option_parser.coffee
- +26 −26 test/test_pattern_matching.coffee
- +23 −15 test/test_ranges_slices_and_splices.coffee
- +12 −12 test/test_regexp_interpolation.coffee
- +5 −5 test/test_regexps.coffee
- +5 −5 test/test_returns.coffee
- +26 −18 test/test_splats.coffee
- +83 −68 test/test_string_interpolation.coffee
- +11 −11 test/test_switch.coffee
- +8 −4 test/test_try_catch.coffee
- +17 −17 test/test_while.coffee
| @@ -1,48 +1,48 @@ | ||
| -fs: require 'fs' | ||
| -{helpers}: require('./lib/helpers') | ||
| -CoffeeScript: require './lib/coffee-script' | ||
| -{spawn, exec}: require('child_process') | ||
| +fs = require 'fs' | ||
| +{helpers} = require './lib/helpers' | ||
| +CoffeeScript = require './lib/coffee-script' | ||
| +{spawn, exec} = require 'child_process' | ||
| # ANSI Terminal Colors. | ||
| -red: '\033[0;31m' | ||
| -green: '\033[0;32m' | ||
| -reset: '\033[0m' | ||
| +red = '\033[0;31m' | ||
| +green = '\033[0;32m' | ||
| +reset = '\033[0m' | ||
| # Run a CoffeeScript through our node/coffee interpreter. | ||
| -run: (args) -> | ||
| - proc: spawn 'bin/coffee', args | ||
| - proc.stderr.addListener 'data', (buffer) -> puts buffer.toString() | ||
| - proc.addListener 'exit', (status) -> process.exit(1) if status != 0 | ||
| +run = (args) -> | ||
| + proc = spawn 'bin/coffee', args | ||
| + proc.stderr.on 'data', (buffer) -> puts buffer.toString() | ||
| + proc.on 'exit', (status) -> process.exit(1) if status != 0 | ||
| # Log a message with a color. | ||
| -log: (message, color, explanation) -> | ||
| - puts "$color$message$reset ${explanation or ''}" | ||
| +log = (message, color, explanation) -> | ||
| + puts "#color#message#reset #{explanation or ''}" | ||
| option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`' | ||
| task 'install', 'install CoffeeScript into /usr/local (or --prefix)', (options) -> | ||
| - base: options.prefix or '/usr/local' | ||
| - lib: "$base/lib/coffee-script" | ||
| - bin: "$base/bin" | ||
| - node: "~/.node_libraries/coffee-script" | ||
| - puts "Installing CoffeeScript to $lib" | ||
| - puts "Linking to $node" | ||
| - puts "Linking 'coffee' to $bin/coffee" | ||
| + base = options.prefix or '/usr/local' | ||
| + lib = "#base/lib/coffee-script" | ||
| + bin = "#base/bin" | ||
| + node = "~/.node_libraries/coffee-script" | ||
| + puts "Installing CoffeeScript to #lib" | ||
| + puts "Linking to #node" | ||
| + puts "Linking 'coffee' to #bin/coffee" | ||
| exec([ | ||
| - "mkdir -p $lib $bin" | ||
| - "cp -rf bin lib LICENSE README package.json src $lib" | ||
| - "ln -sf $lib/bin/coffee $bin/coffee" | ||
| - "ln -sf $lib/bin/cake $bin/cake" | ||
| + "mkdir -p #lib #bin" | ||
| + "cp -rf bin lib LICENSE README package.json src #lib" | ||
| + "ln -sf #lib/bin/coffee #bin/coffee" | ||
| + "ln -sf #lib/bin/cake #bin/cake" | ||
| "mkdir -p ~/.node_libraries" | ||
| - "ln -sf $lib/lib $node" | ||
| + "ln -sf #lib/lib #node" | ||
| ].join(' && '), (err, stdout, stderr) -> | ||
| if err then print stderr else log 'done', green | ||
| ) | ||
| task 'build', 'build the CoffeeScript language from source', -> | ||
| - files: fs.readdirSync 'src' | ||
| - files: 'src/' + file for file in files when file.match(/\.coffee$/) | ||
| + files = fs.readdirSync 'src' | ||
| + files = 'src/' + file for file in files when file.match(/\.coffee$/) | ||
| run ['-c', '-o', 'lib'].concat(files) | ||
| @@ -55,9 +55,9 @@ task 'build:full', 'rebuild the source twice, and run the tests', -> | ||
| task 'build:parser', 'rebuild the Jison parser (run build first)', -> | ||
| require 'jison' | ||
| - parser: require('./lib/grammar').parser | ||
| - js: parser.generate() | ||
| - parserPath: 'lib/parser.js' | ||
| + parser = require('./lib/grammar').parser | ||
| + js = parser.generate() | ||
| + parserPath = 'lib/parser.js' | ||
| fs.writeFile parserPath, js | ||
| @@ -86,34 +86,35 @@ task 'doc:underscore', 'rebuild the Underscore.coffee documentation page', -> | ||
| throw err if err | ||
| -task 'loc', 'count the lines of source code in CoffeeScript', -> | ||
| - exec "cat src/*.coffee | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) -> | ||
| +task 'loc', 'count the lines of source code in the CoffeeScript compiler', -> | ||
| + sources = ['src/coffee-script.coffee', 'src/grammar.coffee', 'src/helpers.coffee', 'src/lexer.coffee', 'src/nodes.coffee', 'src/rewriter.coffee', 'src/scope.coffee'] | ||
| + exec "cat #{ sources.join(' ') } | grep -v '^\\( *#\\|\\s*$\\)' | wc -l | tr -s ' '", (err, stdout) -> | ||
| print stdout | ||
| task 'test', 'run the CoffeeScript language test suite', -> | ||
| helpers.extend global, require 'assert' | ||
| - passedTests: failedTests: 0 | ||
| - startTime: new Date | ||
| - originalOk: ok | ||
| + passedTests = failedTests = 0 | ||
| + startTime = new Date | ||
| + originalOk = ok | ||
| helpers.extend global, { | ||
| ok: (args...) -> passedTests += 1; originalOk(args...) | ||
| CoffeeScript: CoffeeScript | ||
| } | ||
| - process.addListener 'exit', -> | ||
| - time: ((new Date - startTime) / 1000).toFixed(2) | ||
| - message: "passed $passedTests tests in $time seconds$reset" | ||
| + process.on 'exit', -> | ||
| + time = ((new Date - startTime) / 1000).toFixed(2) | ||
| + message = "passed #passedTests tests in #time seconds#reset" | ||
| if failedTests | ||
| - log "failed $failedTests and $message", red | ||
| + log "failed #failedTests and #message", red | ||
| else | ||
| log message, green | ||
| fs.readdir 'test', (err, files) -> | ||
| files.forEach (file) -> | ||
| return unless file.match(/\.coffee$/i) | ||
| - source: path.join 'test', file | ||
| - fs.readFile source, (err, code) -> | ||
| + fileName = path.join 'test', file | ||
| + fs.readFile fileName, (err, code) -> | ||
| try | ||
| - CoffeeScript.run code.toString(), {source: source} | ||
| + CoffeeScript.run code.toString(), {fileName} | ||
| catch err | ||
| failedTests += 1 | ||
| - log "failed $source", red, '\n' + err.stack.toString() | ||
| + log "failed #fileName", red, '\n' + err.stack.toString() | ||
| @@ -6,7 +6,7 @@ require 'yui/compressor' | ||
| HEADER = <<-EOS | ||
| /** | ||
| - * CoffeeScript Compiler v0.7.2 | ||
| + * CoffeeScript Compiler v0.9.0 | ||
| * http://coffeescript.org | ||
| * | ||
| * Copyright 2010, Jeremy Ashkenas | ||
| @@ -17,7 +17,7 @@ EOS | ||
| desc "Build the documentation page" | ||
| task :doc do | ||
| source = 'documentation/index.html.erb' | ||
| - child = fork { exec "bin/coffee -c documentation/coffee/*.coffee -o documentation/js -w" } | ||
| + child = fork { exec "bin/coffee --no-wrap -cw -o documentation/js documentation/coffee/*.coffee" } | ||
| at_exit { Process.kill("INT", child) } | ||
| Signal.trap("INT") { exit } | ||
| loop do | ||
| @@ -1,11 +1,11 @@ | ||
| launch() if ignition is on | ||
| -volume: 10 if band isnt SpinalTap | ||
| +volume = 10 if band isnt SpinalTap | ||
| letTheWildRumpusBegin() unless answer is no | ||
| if car.speed < limit then accelerate() | ||
| -winner: yes if pick in [47, 92, 13] | ||
| +winner = yes if pick in [47, 92, 13] | ||
| -print "My name is " + @name | ||
| +print inspect "My name is " + @name |
| @@ -1,5 +1,5 @@ | ||
| # Eat lunch. | ||
| -lunch: eat food for food in ['toast', 'cheese', 'wine'] | ||
| +lunch = eat food for food in ['toast', 'cheese', 'wine'] | ||
| # Naive collision detection. | ||
| for roid in asteroids | ||
| @@ -1,2 +0,0 @@ | ||
| -greeting: "Hello CoffeeScript" | ||
| -difficulty: 0.5 |
| @@ -0,0 +1,4 @@ | ||
| +### | ||
| +CoffeeScript Compiler v0.9.0 | ||
| +Released under the MIT License | ||
| +### |
| @@ -1,3 +1,9 @@ | ||
| -task 'test', 'run each of the unit tests', -> | ||
| - for test in files | ||
| - fs.readFile test, (err, code) -> eval coffee.compile code | ||
| +fs = require 'fs' | ||
| + | ||
| +option '-o', '--output [DIR]', 'directory for compiled code' | ||
| + | ||
| +task 'build:parser', 'rebuild the Jison parser', -> | ||
| + require 'jison' | ||
| + code = require('./lib/grammar').parser.generate() | ||
| + dir = options.output or 'lib' | ||
| + fs.writeFile "#dir/parser.js", code |
| @@ -1,25 +1,21 @@ | ||
| class Animal | ||
| + constructor: (@name) -> | ||
| + | ||
| move: (meters) -> | ||
| alert @name + " moved " + meters + "m." | ||
| class Snake extends Animal | ||
| - constructor: (name) -> | ||
| - @name: name | ||
| - | ||
| move: -> | ||
| alert "Slithering..." | ||
| super 5 | ||
| class Horse extends Animal | ||
| - constructor: (name) -> | ||
| - @name: name | ||
| - | ||
| move: -> | ||
| alert "Galloping..." | ||
| super 45 | ||
| -sam: new Snake "Sammy the Python" | ||
| -tom: new Horse "Tommy the Palomino" | ||
| +sam = new Snake "Sammy the Python" | ||
| +tom = new Horse "Tommy the Palomino" | ||
| sam.move() | ||
| tom.move() | ||
| @@ -1,5 +1,5 @@ | ||
| -cholesterol: 127 | ||
| +cholesterol = 127 | ||
| -healthy: 200 > cholesterol > 60 | ||
| +healthy = 200 > cholesterol > 60 | ||
| @@ -1,9 +1,11 @@ | ||
| -mood: greatlyImproved if singing | ||
| +mood = greatlyImproved if singing | ||
| if happy and knowsIt | ||
| clapsHands() | ||
| chaChaCha() | ||
| +else | ||
| + showIt() | ||
| -date: if friday then sue else jill | ||
| +date = if friday then sue else jill | ||
| -options: or defaultOptions | ||
| +options or= defaults |
| @@ -1,4 +1,4 @@ | ||
| -hi: `function() { | ||
| +hi = `function() { | ||
| return [document.title, "Hello JavaScript"].join(": "); | ||
| }` | ||
| @@ -1,4 +1,4 @@ | ||
| -solipsism: true if mind? and not world? | ||
| +solipsism = true if mind? and not world? | ||
| speed ?= 140 | ||
| @@ -1,9 +1,9 @@ | ||
| -grade: (student) -> | ||
| +grade = (student) -> | ||
| if student.excellentWork | ||
| "A+" | ||
| else if student.okayStuff | ||
| if student.triedHard then "B" else "B-" | ||
| else | ||
| "C" | ||
| -eldest: if 24 > 21 then "Liz" else "Ike" | ||
| +eldest = if 24 > 21 then "Liz" else "Ike" |
| @@ -1 +1 @@ | ||
| -six: (one: 1) + (two: 2) + (three: 3) | ||
| +six = (one = 1) + (two = 2) + (three = 3) |
| @@ -1,3 +1,3 @@ | ||
| # The first ten global properties. | ||
| -globals: (name for name of window)[0...10] | ||
| +globals = (name for name of window)[0...10] |
| @@ -1,6 +1,6 @@ | ||
| -Account: (customer, cart) -> | ||
| - @customer: customer | ||
| - @cart: cart | ||
| +Account = (customer, cart) -> | ||
| + @customer = customer | ||
| + @cart = cart | ||
| $('.shopping_cart').bind 'click', (event) => | ||
| @customer.purchase @cart |
| @@ -1,2 +1,2 @@ | ||
| -square: (x) -> x * x | ||
| -cube: (x) -> square(x) * x | ||
| +square = (x) -> x * x | ||
| +cube = (x) -> square(x) * x |
| @@ -1,5 +1,5 @@ | ||
| -html: ''' | ||
| - <strong> | ||
| - cup of coffeescript | ||
| - </strong> | ||
| - ''' | ||
| +html = ''' | ||
| + <strong> | ||
| + cup of coffeescript | ||
| + </strong> | ||
| + ''' |
| @@ -1,2 +1,2 @@ | ||
| -author: "Wittgenstein" | ||
| -quote: "A picture is a fact. -- $author" | ||
| +author = "Wittgenstein" | ||
| +quote = "A picture is a fact. -- #author" |
| @@ -1,6 +1,6 @@ | ||
| -sentence: "${ 22 / 7 } is a decent approximation of π" | ||
| +sentence = "#{ 22 / 7 } is a decent approximation of π" | ||
| -sep: "[.\\/\\- ]" | ||
| -dates: /\d+$sep\d+$sep\d+/g | ||
| +sep = "[.\\/\\- ]" | ||
| +dates = /\d+#sep\d+#sep\d+/g | ||
| @@ -1,5 +1,5 @@ | ||
| -weatherReport: (location) -> | ||
| +weatherReport = (location) -> | ||
| # Make an Ajax request to fetch the weather... | ||
| [location, 72, "Mostly Sunny"] | ||
| -[city, temp, forecast]: weatherReport "Berkeley, CA" | ||
| +[city, temp, forecast] = weatherReport "Berkeley, CA" |
| @@ -1,4 +1,4 @@ | ||
| -yearsOld: {max: 10, ida: 9, tim: 11} | ||
| +yearsOld = max: 10, ida: 9, tim: 11 | ||
| -ages: for child, age of yearsOld | ||
| +ages = for child, age of yearsOld | ||
| child + " is " + age |
| @@ -1,13 +1,11 @@ | ||
| -futurists: { | ||
| +futurists = | ||
| sculptor: "Umberto Boccioni" | ||
| painter: "Vladimir Burliuk" | ||
| - poet: { | ||
| + poet: | ||
| name: "F.T. Marinetti" | ||
| address: [ | ||
| "Via Roma 42R" | ||
| "Bellagio, Italy 22021" | ||
| ] | ||
| - } | ||
| -} | ||
| -{poet: {name, address: [street, city]}}: futurists | ||
| +{poet: {name, address: [street, city]}} = futurists |
Showing you all comments on commits in this comparison.
|
I suggest we also add a test:
just to be sure proper inheritance is in place? |
|
Instead of wrapping the entire body of the for loop in a big hasOwnProperty conditional, wouldn't it be faster and cleaner to just "continue;" if hasOwnProperty? |
|
Great idea. Simpler control flow, simpler compilation, same run time. It's landed in master -- here's the patch: http://github.com/jashkenas/coffee-script/commit/6c8eab7af560634b62f7d5bb1831147ec3b342d9 Thanks for the suggestion. |
|
I always kind of like doing:
so in a way documenting the passed in arguments. There is no way telling what |
|
A very good point. I've changed the method signature to take an options hash instead: http://github.com/jashkenas/coffee-script/commit/1dab47176b103684abd7cba74b05316f7864ada2 |
|
Temporary variables are one character long and prefixed with a single underscore. Utility functions start with two underscores. I reckon we should pick either of these to use for the redefined |
Syntax Error. You mean this? Or this: |
|
nope -- I meant the first one. The parentheses we're generating fix the JavaScript syntax error that would otherwise be produced by this CoffeeScript:
|
|
Uh huh. So the issue is not about operator precedence, but statement vs expression. Then I think the right result should be: |
|
This isn't testing it right ( |
|
Quite right -- thanks for catching it. Fixed here: http://github.com/jashkenas/coffee-script/commit/0aa36899a8cbc032a1e8f5d0035fe90bc265d428 |
|
I wonder if this can be written as:
i.e., make use of any native or framework implementation that already exists? |
|
See here: http://github.com/evilpie/coffee-script/commit/67183be135eedb2b09b35e98d3de516f92e885a4 |
|
It is not going to work as is, but the point is to cache the reference to an existing implementation and not check for it every time |
|
And why don't we simply supply an ES5-compatible Function.prototype.bind if one does not exist? Then it can just be assumed that it exists. I've implemented it in both coffeescript and javascript here: http://gist.github.com/503393/ |
|
@michaelficarra:: that's more of a task for a framework than CoffeeScript. Extending natives is not done anywhere else in the core and it's a bad place to go. I like the code, though. |
|
Yeah, I kind of figured that. It's just such a sensible place to put it, but I understand why coffeescript may not want to alter the natives. The reason I thought it may be okay is because someone shouldn't be relying on its nonexistence, given that it is part of ES5. |
|
Just ran this on Node.js master (not to be taken too seriously):
And wow! If it is to be any measurement of speed, I guess Coffee's little |
|
Yep, I had originally merged evilpie's branch to master, but then backed it out after digging around. Various browsers have implemented |
|
I reckon we need an FAQ document where we can collect these little notes. There have been questions on the tracker about including other files on a few occasions ans since GitHub search in issues sucks big time, everyone would benefit from a doc with notes on common questions. |
|
Nit picking, but there's a bug in this example - it should be $('.account').attr class: 'active' - the jQuery CSS method doesn't modify the HTML class attribute |
|
Ah, but of course -- nice catch. Fixed here: 8f8c4b4 |