GithubHelp home page GithubHelp logo

coco's People

Contributors

alotofnoodles avatar brodyberg avatar cehoffman avatar chrislloyd avatar dpritchett avatar drnic avatar gfodor avatar holmsand avatar hugs avatar jashkenas avatar leobm avatar matehat avatar michaelficarra avatar noonat avatar olsonjeffery avatar satyr avatar srijs avatar sstephenson avatar stanangeloff avatar tanob avatar tim-smart avatar track-com avatar trevorburnham avatar vendethiel avatar zaach avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

coco's Issues

`let` over `do` for scope introduction

Reasons

  • Scope mixups:

    a = 1
    say do     (a = a) -> a  # 1
    say do []= (a = a) -> a  # undefined
    
  • do being a simple sugar for () is consistent and easier to grok.

Syntax

let (a = b) -> # (function(a){})(b)
let (a) ->     # (function(a){})(a)
let (@a) ->    # (function(a){})(this.a)
let ~>         # (function(){}).call(this)

anaphoric

return that if get()


var that;
if (that = get()) {
return that;
}

thisplat

f ...


f.apply(this, arguments);

fallthrough

switch task
case prepare
  do sing
  fallthrough  # prevents auto-break
default
  do dance


switch (task) {
case prepare:
sing();
default:
dance();
}

`import` aliases

  • They are kind of verbose, and don't read well when combined with other symbols (such as @:: import ...).
  • Can act as replacements after harmony defines import for real.

<<< for import, <<<< for import all?

`import` shortcut

Should be able to optimize if the right operand is a bare array/object.
C:: import d: e, (f): g

var _ref;
_ref = C.prototype, _ref.d = e, _ref[f] = g;

edit: On second thought, array case is pretty pointless.

Optimize `if` compilation using comma operator

ok = if cond
  expr()
  true
else
  false

Before

var ok;
ok = (function(){
  if (cond) {
    expr();
    return true;
  } else {
    return false;
  }
}());

After

var ok;
ok = cond ? (expr(), true) : false;

Support do (x) ->

Currently, do (x = y) -> ... compiles to

(function(x){
  x == null && (x = y);
  ...
}());

which is really just an inefficient way of writing

(function(x){
  ...
}(y));

Changing do to rewrite in this way would also allow you to write do (x = x), which currently is nonsensical, to capture a particular value of x (useful in loops).

I would also suggest that do (x) be made a shorthand for do (x = x).

Speed up lexer

$ git log -1 --format=oneline
4a67699c0e66707299fe22c3311c3be35b4fe4f grammar: removed Case

$ coke bench
Lex     : 1026[ms] (18388 tokens)
Rewrite :  135[ms] (20772 tokens)
Parse   :  150[ms]
Compile :  212[ms] (119587 chars)
TOTAL   : 1523[ms]

bound constructor

class C
  (@attr) =>

var C;
C = (function(){
  function C(_arg){
    var _this = new _ctor;
    _this.attr = _arg;
    return _this;
  }
  C.name = "C";
  function _ctor(){}
  _ctor.prototype = C.prototype;
  return C;
}());

typo in readme

Install instructions state:
git clone git:github.com/satyr/coco.git && cd coco && bin/coke i

But should be:
git clone git://github.com/satyr/coco.git && cd coco && bin/coke i

implicit arrays

The property syntax is already special in allowing an indented expression as RHS:
$ coco -bpe '
> k:
> 1
> '
({
k: 1
});
But not block:
$ coco -bpe '
> k:
> 1
> 2
> '
Error: Parse error on line 3: Unexpected 'TERMINATOR'
Allowing the latter as an implicit array literal seems reasonable.

Support language filters?

Would it a terrible idea to allow other languages within coco?

Here's a simple example of what I am thinking:

paragraph = 
    :markdown
    Hello, 
    ======
    Today is a *fine* day.

$('#welcome-message').inject paragraph

The :markdown is just an example of how one might signify the beginning of a new language block. I guess coco would need to have a 'hook' for authors to plugin/reference other language compilers. I imagine it wouldn't be too hard to manage that part. The issue may be more the usefulness of such a feature, and enough use-cases to make it worthwhile.

Enhance <<< and <<<<

Currently the import or <<< feature is handy but a version that allows for only undefined values to be imported would help I think.

Below is a common use-case:

human = (args)->
    defaults =
        height: 6
        hair: 'brown'

    args <<< defaults
    console.log args, defaults


human do
    country: 'canada'
    job: 'mail man'
    height: 3

In this example, defaults.height overrides args.height.

Maybe the syntax could be something like:

<<<?
<<<<?

I am not sold on those at all, just potentials.
Maybe we could change <<< to behave non-destructively by default. Then we could provide bang syntax to force overrides, like such:

<<<!
<<<<!

Support labels

The current workaround (L:break L;) is too awkward.

npm install coco link bin error

Apparently there is a problem with package.json. According to isaacs the bin hash should be filenames not module ids.

~ $ npm install coco --loglevel verbose npm info it worked if it ends with ok
npm verb cli [ 'install',
npm verb cli 'coco',
npm verb cli '--loglevel',
npm verb cli 'verbose' ]
npm info using [email protected]
npm info using [email protected]
npm verb config file /Users/stuarts/.npmrc
npm verb config file /Users/stuarts/local/etc/npmrc
npm verb install [ 'coco' ]
npm verb install [ 'coco' ]
npm verb install pkglist [ 'coco' ]
npm verb must install [ 'coco' ]
npm verb install coco
npm verb must install? [ [ 'coco' ], true ]
npm verb GET coco
npm verb etag "2V412V9E96NYDOLEOXV5L3HMB"
npm verb response http://registry.npmjs.org/coco npm verb etag coco from cache
npm verb Supported versions [ '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]',
npm verb Supported versions '[email protected]' ]
npm verb coco tag latest
npm verb install [email protected]
npm verb must install? [ [ 'coco', '0.3.2' ],
npm verb must install? true ]
npm verb [email protected] exact
npm verb caching /Users/stuarts/local/lib/node/.npm/.cache/coco/0.3.2/package.json
npm verb install list [ [ 'coco', '0.3.2' ] ]
npm verb mkdir done: /Users/stuarts/local/lib/node/.npm/coco/0.3.2
npm verb unpackTar uid, gid [ undefined, undefined ]
npm verb success gzip "--decompress" "--stdout" "/Users/stuarts/local/lib/node/.npm/.cache/coco/0.3.2/package.tgz"
npm verb success tar "-mvxpf" "-" "-C" "/Users/stuarts/local/lib/node/.npm/coco/0.3.2"
npm verb unpacked, building coco,0.3.2
npm verb caching /Users/stuarts/local/lib/node/.npm/coco/0.3.2/package/package.json
npm info preinstall [email protected]
npm verb deps being resolved [ { name: 'coco',
npm verb deps being resolved description: 'Unfancy CoffeeScript',
npm verb deps being resolved keywords:
npm verb deps being resolved [ 'language',
npm verb deps being resolved 'compiler',
npm verb deps being resolved 'coffeescript',
npm verb deps being resolved 'javascript' ],
npm verb deps being resolved author:
npm verb deps being resolved { name: 'satyr',
npm verb deps being resolved email: '[email protected]',
npm verb deps being resolved url: 'http://satyr.github.com' },
npm verb deps being resolved version: '0.3.2',
npm verb deps being resolved homepage: 'http://satyr.github.com/coco/',
npm verb deps being resolved repository:
npm verb deps being resolved { type: 'git',
npm verb deps being resolved url: 'git://github.com/satyr/coco.git' },
npm verb deps being resolved licenses:
npm verb deps being resolved [ { type: 'MIT',
npm verb deps being resolved url: 'https://github.com/satyr/coco/raw/master/LICENSE' } ],
npm verb deps being resolved engines: { node: '>=0.2.6' },
npm verb deps being resolved directories: { lib: './lib', bin: './bin' },
npm verb deps being resolved main: './lib/coco',
npm verb deps being resolved bin:
npm verb deps being resolved { coco: './lib/command',
npm verb deps being resolved coke: './lib/coke' },
npm verb deps being resolved id: '[email protected]',
npm verb deps being resolved engineSupported: true,
npm verb deps being resolved npmVersion: '0.3.15',
npm verb deps being resolved nodeVersion: 'v0.4.2',
npm verb deps being resolved files: [ '' ],
npm verb deps being resolved defaultsLoaded: true,
npm verb deps being resolved dist:
npm verb deps being resolved { shasum: 'd5aff68b204e5f5f84f7db0298b2af6d2da3370e',
npm verb deps being resolved tarball: 'http://registry.npmjs.org/coco/-/coco-0.3.2.tgz' },
npm verb deps being resolved _bundledDeps: [] },
npm verb deps being resolved [] ]
npm verb linkBins [email protected]
npm verb linkBin coco ./lib/command
npm verb linkBin coke ./lib/coke
npm verb linkMans [email protected]
npm ERR! failed to link bins
npm ERR! install failed Error: ENOENT, No such file or directory '/Users/stuarts/local/bin/[email protected]'
npm info install failed rollback
npm info uninstall [ '[email protected]' ]
npm verb removing [ [ 'coco', '0.3.2' ] ]
npm verb from cache /Users/stuarts/local/lib/node/.npm/coco/0.3.2/package/package.json
npm info preuninstall [email protected]
npm info uninstall [email protected]
npm info auto-deactive not symlink
npm verb uninstall [email protected] remove links
npm verb uninstall [email protected] remove bins
npm verb uninstall [email protected] remove public modules
npm info postuninstall [email protected]
npm verb uninstall [email protected] remove package dir
npm info uninstall [email protected] complete
npm info install failed rolled back
npm ERR! Error: ENOENT, No such file or directory '/Users/stuarts/local/bin/[email protected]'
npm ERR! Report this entire log at http://github.com/isaacs/npm/issues
npm ERR! or email it to [email protected]
npm ERR! Just tweeting a tiny part of the error will not be helpful.
npm ERR! System Darwin 10.6.0
npm ERR! argv { remain: [ 'coco' ],
npm ERR! argv cooked:
npm ERR! argv [ 'install',
npm ERR! argv 'coco',
npm ERR! argv '--loglevel',
npm ERR! argv 'verbose' ],
npm ERR! argv original:
npm ERR! argv [ 'install',
npm ERR! argv 'coco',
npm ERR! argv '--loglevel',
npm ERR! argv 'verbose' ] }
npm verb exit [ 2, true ]
npm not ok

number comments

Allow arbitrary trailing alphabets, for specifying units etc.

setTimeout cb, 512ms

day = 24hours * 60seconds

return-if

return if get()

var _ref;
if (_ref = get()) return _ref;

Manual install leads to Error: Cannot find module './optparse'

When installing coco manually using readme instructions, the following occurs:

node.js:63
    throw e;
    ^s:275:15)
    at require (node.js:411:14)
    at Object.<anonymous> (/Users/KUHRT/coco/bin/coco:20:5)
    at Module._compile (node.js:462:23)
    at Module._loadScriptSync (node.js:469:10)
    at Module.loadSync (node.js:338:12)
    at loadModule (node.js:283:14)
    at require (node.js:411:14)
    at Object.<anonymous> (/Users/KUHRT/coco/bin/coke:11:15)
    at Module._compile (node.js:462:23)

I can overcome this by manually copying the optpase file from the lib directory to the bin directory. I also npm'd optparse but haven't tried loading the module from there (after I realized the problem code was using a local path). I see that you've symlinked the coke file to bin so I am not sure why this is happening.

Am I doing something wrong?

Support get/set

With syntax like:

obj = {
  prop: function -> 42
  prop: function (item) -> alert item
}

var obj;
obj = {
  get prop(){
    return 42;
  },
  set prop(item){
    return alert(item);
  }
};

Keep `arguments` across statement wrappers

So that this:
$ coco -e 'console.log arguments is (switch case 1 then arguments)'
false
results in true.

Before

console.log(arguments === (function(){
  switch (false) {
  case !1:
    return arguments;
  }
}.apply(this, arguments)));

After

console.log(arguments === (function(_args){
  switch (false) {
  case !1:
    return _args;
  }
}(arguments)));

Make JS literal smarter

So that hacks like

`EXIT:`
for i from 3 to 5
  for j from 7 to 9
    `break EXIT` if Math.random() < .2
    say i * j

works as expected.

Make `delete` return the original value

Since the return value of JS delete is hardly useful and rarely used.
v = delete o.p
delete o.k

var _ref;
v = (_ref = o.k, delete o.k, ref);
delete o.k;

numeric ranges

[1 to 3]
[1 to 5 by 2]

[1, 2, 3]
[1, 3, 5]

Should be able to expand within lexer.

Make `super` a literal

Now that you can super ... instead of super (which compiles to the same thing), make it a literal for greater flexibility (such as a.map super.bind this).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.