Git Product home page Git Product logo

brushtail's People

Contributors

licentious avatar michaelficarra avatar puffnfresh 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

brushtail's Issues

support NFEs

For some reason, all function expressions are ignored, even though NFEs have letrec semantics.

Live coding example

Put it on your website, in your blog, or even on github pages if you must. Just create an example people can play with, without having to pull.

Publish to npm

Would be great to be able to just add it as a dependency.

Doesn't handle shadowed tco label

If the function to transform has a label tco it gets shadowed:

function a(n) {
   tco: {
     return a(n);
   }
}
function a(n) {
    var __tcor;
    tco:
        while (true) {
            tco: {
                {
                    var __n = n;
                    n = __n;
                    continue tco;
                }
            }
        }
    return __tcor;
}

removing closure for performance boost

One of the key advantages for tail recursion is often that the compiler can find ways to optimize the loop to increase performance. But unfortunately this performance boost is destroyed by the closure in the mutated version. By removing the closure there is a massive performance increase on my machine around 800%.

http://jsperf.com/tail-recursion-test

Question is, are there efforts to remove the closure?

Code breaks when using Continuation-passing style

The following code breaks.

function factorial_cps(n, k) {
  if (n === 0) return k(1);
  return factorial_cps(
    n - 1, 
    function(result) { 
      return k(n * result); 
    });
}


function identity(x) { return x; }

var f = factorial_cps(5, identity); // 120

console.log(f); 

The problem is the

    __k = function (result) {
                    {
                        __tcor = k(n * result);
                        break tco;
                    }}

Which simply doesn't work. I guess there is no trivial solution for that but it would be very cool to be able to transform CPS code.

Generate fresh identifiers

Shouldn't be too tricky. Traverse the AST looking for identifiers, store them in a set and try generating a fresh identifier.

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.