is a CoffeeScript dialect that aims to be more radical and practical.
On its way to hide JavaScript's bad parts, CoffeeScript has accumulated own quirks: horrible variable scope, awkward ranges, confusing and/or pointless keywords, verbose file extension, and so on. Coco tries to amend them, entwining good parts of both.
npm i -g coco
git clone git://github.com/satyr/coco.git && cd coco && bin/coke i
if
-block. (#151)for
-let
. (#164)<>
aka lef. (#180)|>
the lowest precedence.`
, close with N+1 `
:
``` '``' ```
--json
.&
is now used to reference several new targets:
|>
(in place of _
).for [0 1] => &+2 # [2 3]
with
as proposed
in #172.with
in disguise, require at least one &
in body.
(#179)let
accept this =
on the first assignment to substitute old with
.catch
return the catchee.by -1
implied on downward ranges.#&
and #@
.super
followed by ::
to parent method,
so that call to super::anotherMethod
works as expected.encode-URI-component
=> encodeURIComponent
|>
.=>
as another block creation operator.export
/import
/const
/var
can now appear anywhere.catch
ed variables are now function-scoped.
(coffee#2422)$
rather than prefix __
.export const
....:
.+
for array concatenation.class
can be bodyless again.super
no longer auto-.call
s more than once.implements
. (#144)void
s are now simply ignored and usable like Python's pass.import
declaration in place of the implicit this import
:
import a, b
=> this <<< a <<< b
super
work in accessor methods.var
.const
and var
. (#139)function
variables read-only.-n
shorthand for --nodejs
.
(#142)<-:f g
=> g(:f ->)
{[q]:p}
short for {p: [q]:p}
.export
statement. (#121){{q}:p}
short for {p: {q}:p}
.{true}
=> {true: true}
$
in number comments.:f ->
compiles to (function f(){})
.super
call to a bound class now works as expected.--interactive
no longer implies --bare
.
Use -bi
when you want top-level variables to persist.!
against function/backcall now suppresses its auto-return.superclass
now points to the constructor that the class extends
.super
now relies solely on superclass
rather than requiring special forms like C::m = ->
.of
no longer delegates to Array::indexOf
, making it consistent with for
-of
behavior.if
/for
/while
/until
.--print
no longer implies --compile
.--watch
now works on Windows.!! = x
=> x = !!x
a? <<< b
short for a <<< b if a?
.case
/of
/instanceof
now works better with array slice.instanceof
now rejects invalid right operands.+[a, b]
=> [+a, +b]
..
now points to the constructor under class
.f! => g _
=> _ = f!; g _
[\a to \d]
=> [\a \b \c \d]
{p, q}:o = f!
=> o = f!; {p, q} = o
.
.function
can no longer prefix ->
/~>
.
Use ~function
to declare bound functions instead.for
prepositions.import
ing onto a soaked expression is now safe.--json
now modifies --ast
or --compile
.<?
and >?
operators.else
clause.import x
is now short for this <<< x
.,
after (
, [
or another ,
now implies void
.f!
=> f()
x{}
to ^x
..!
/.@
to .@
/.@@
."(#id)"
=> "(" + id + ")"
super
now delegate this
.extended
hook is back.from
of for
is now optional, meaning from 0
.
til
less from
is no longer allowed.while
/until
can now have update clause after test clause:
continue while f(), g()
=> for (; f(); g()) {}
that
no longer triggers anaphoric conversion under unless
/until
.a.=b = c
p:~ (a, b) ->
f ..., a
etc.do
-while
/until
construction.$
flag to regexes. Same as .source
, but more efficient.new
ed/setter functions.!?
(inexistence) operator.function
no longer requires parens around parameters.class
block is now mandatory.a.b.c?.=d.e
now works as expected.a[b, c] = d
now works as expected.--output
implies --compile
again.**
operator.+
/-
//
(in addition to *
) for arrays and strings.let
: let (a) ~>
=> let a then
/// re ///
=> // re //
->
is now optional when function
is used.case
accepts comma-separated tests again.return
/throw
can now take a block.?.
++
/--
*
s serve like list markers.constructor
as ..
.let
. Unary do
is back at being simple call.with
.::
a pure sugar for prototype
, which can now directly refer to @::
under class body.?.
can now appear anywhere a normal dot can be used.~.
is changed to . ~
.new
no longer accepts splatted arguments.--interactive
now works with --compile
and --bare
.--nodes
option and .nodes
method to --ast
/.ast
.@
and ::
.@foo
.typeof!
, which inspects the internal [[Class]] property.debugger
now works anywhere.///#{x}#{y}///?
-> RegExp('' + x, y);
Coco.eval
.--json
option.do
block can now work as a pair of normal parentheses.f {} [] x
-> f({}, [], x);
@@0'!'
-> arguments[0]['!'];
/// x #{? y } ///
-> RegExp('x', y);
a.+=b
-> a += a.b;
...
in array destructuring (same as ...[]
) now skips items rather than slice
ing them. (coffee#870)Coco
object now emits more events for use with --require
.=>
~>
&.
~.
/* */
.@0
is now this[0]
rather than arguments[0]
.is not
is the new isnt
.@'++'
is now valid as a shorthand for @['++']
.(a || b) ->
instead of (a ||= b) ->
)do
now performs special conversions against function literals with parameters,
making it work as pseudo-let
and Coffee 1.0.0 compliant.for i from x then
as a sugar for for i from 0 til x then
.@@
is now a shorthand for arguments
.do
can now indicate a call against indented arguments.and
and or
now close implicit calls, making you write even less parens:
f x and g y or z
-> f(x) && g(y) || z;
catch
's variable declaration is no longer required.a<[ b c ]>
is now equivalent to a[\b, \c]
(was a(\b, \c)
).case
now requires brackets to have multiple conditions.--nodejs
option. See coffee#910.--stdio
to --stdin
.\C + \++
-> 'C' + '++';
a[b, c]
-> [a[b], a[c]];
a[b, c] = d
-> a[b] = d[0], a[c] = d[1];
a{b, c} = d
-> a.b = d.b, a.c = d.c;
[@a, @b] /= c
-> this.a /= c[0], this.b /= c[1];
that
within if
, while
or case
block now refers to the condition value.9times
, 1.5s
<<<
/<<<<
as aliases to import
/import all
.
and its families can now be used with numbers and strings, instead of []
.
a.0.'0'
compiles to a[0]['0']
.obj{key:val}
acts like a simple version of ES5 Object.create
,
creating a prototypal child of obj
and assigning to .key
with val
.||
/&&
.super
under a class block now refers to the superclass.[]
/{}
can now be safely used as an placeholder within array destructuring.--nodes
output....
is now prefix.{0: first, (*-1): last} = array
now works.--lex
to the coco
utility. Removed --lint
.Release.