Unfancy JavaScript
Go to file
Simon Lydell 8ab15d7372 Fix #1500, #1574, #3318: Name generated vars uniquely
Any variables generated by CoffeeScript are now made sure to be named to
something not present in the source code being compiled. This way you can no
longer interfere with them, either on purpose or by mistake. (#1500, #1574)

For example, `({a}, _arg) ->` now compiles correctly. (#1574)

As opposed to the somewhat complex implementations discussed in #1500, this
commit takes a very simple approach by saving all used variables names using a
single pass over the token stream. Any generated variables are then made sure
not to exist in that list.

`(@a) -> a` used to be equivalent to `(@a) -> @a`, but now throws a runtime
`ReferenceError` instead (unless `a` exists in an upper scope of course). (#3318)

`(@a) ->` used to compile to `(function(a) { this.a = a; })`. Now it compiles to
`(function(_at_a) { this.a = _at_a; })`. (But you cannot access `_at_a` either,
of course.)

Because of the above, `(@a, a) ->` is now valid; `@a` and `a` are not duplicate
parameters.

Duplicate this-parameters with a reserved word, such as `(@case, @case) ->`,
used to compile but now throws, just like regular duplicate parameters.
2015-01-10 23:25:01 +01:00
bin Moved src/*.coffee under src/coffee-script/ so that lib can be added to $NODE_PATH and only expose the top-level coffee-script namespace. Fixes #1246 2011-07-05 21:58:04 +10:00
documentation include logo .svg files 2014-12-02 18:33:07 -06:00
examples Export the CoffeeScript REPL. 2014-04-18 08:26:51 -05:00
extras CoffeeScript 1.8.0 2014-08-26 12:24:29 -04:00
lib/coffee-script Fix #1500, #1574, #3318: Name generated vars uniquely 2015-01-10 23:25:01 +01:00
src Fix #1500, #1574, #3318: Name generated vars uniquely 2015-01-10 23:25:01 +01:00
test Fix #1500, #1574, #3318: Name generated vars uniquely 2015-01-10 23:25:01 +01:00
.gitignore ignore litcoffee files 2012-09-25 17:50:04 -05:00
.npmignore fixes issue #1490 ... jsl.conf is incorrectly npmignored. 2011-07-06 22:15:35 -04:00
CNAME trying with just the .org 2011-10-31 22:54:32 -04:00
CONTRIBUTING.md now that github supports renames, coffeescript, not coffee-script 2014-05-08 15:07:42 -04:00
Cakefile Merge remote-tracking branch 'A/master' 2014-09-06 11:32:25 +02:00
LICENSE CoffeeScript 1.7.0 2014-01-28 14:05:38 -05:00
README now that github supports renames, coffeescript, not coffee-script 2014-05-08 15:07:42 -04:00
README.md `bin/cake` will be in `coffeescript` 2014-07-17 15:04:40 -07:00
bower.json Removed "mkdirp": "~0.3.5" from bower.json 2014-10-29 15:10:57 -05:00
index.html Add Atom to Examples 2014-08-27 21:24:42 -07:00
package.json Merge remote-tracking branch 'A/master' 2014-09-06 11:32:25 +02:00
register.js fix auto and manual require.extensions registration; ref #3141 2013-12-08 14:19:10 -06:00
repl.js Export the CoffeeScript REPL. 2014-04-18 08:26:51 -05:00

README.md

        {
     }   }   {
    {   {  }  }
     }   }{  {
    {  }{  }  }                    _____       __  __
   { }{ }{  { }                   / ____|     / _|/ _|
 .- { { }  { }} -.               | |     ___ | |_| |_ ___  ___
(  { } { } { } }  )              | |    / _ \|  _|  _/ _ \/ _ \
|`-..________ ..-'|              | |___| (_) | | | ||  __/  __/
|                 |               \_____\___/|_| |_| \___|\___|
|                 ;--.
|                (__  \            _____           _       _
|                 | )  )          / ____|         (_)     | |
|                 |/  /          | (___   ___ _ __ _ _ __ | |_
|                 (  /            \___ \ / __| '__| | '_ \| __|
|                 |/              ____) | (__| |  | | |_) | |_
|                 |              |_____/ \___|_|  |_| .__/ \__|
 `-.._________..-'                                  | |
                                                    |_|

CoffeeScript is a little language that compiles into JavaScript.

Installation

If you have the node package manager, npm, installed:

npm install -g coffee-script

Leave off the -g if you don't wish to install globally. If you don't wish to use npm:

git clone https://github.com/jashkenas/coffeescript.git
sudo coffeescript/bin/cake install

Getting Started

Execute a script:

coffee /path/to/script.coffee

Compile a script:

coffee -c /path/to/script.coffee

For documentation, usage, and examples, see: http://coffeescript.org/

To suggest a feature or report a bug: http://github.com/jashkenas/coffeescript/issues

If you'd like to chat, drop by #coffeescript on Freenode IRC.

The source repository: https://github.com/jashkenas/coffeescript.git

Our lovely and talented contributors are listed here: http://github.com/jashkenas/coffeescript/contributors