Giter Club home page Giter Club logo

Comments (8)

dakotamurphyucf avatar dakotamurphyucf commented on June 23, 2024 1

@xtuc yea I completely overlooked that _state was being declared in the while loop and so you are right the automatically invoked curried function is not needed

I know safari figured out a way to implement TCO to spec so it definitely must be doable

Thinking more about it, I agree it is probably not a safe assumption.

We should be able to detect a closure in a closure and throw, I guess shadowing and scoping will become complicated. Just to avoid breaking the state for outer functions.

Could you elaborate a little more? Sorry if I am completely missing something I am pretty new to this subject 😆

I should have a pull-request ready by the end of the week to with a P.O.C.

from babel-plugin-tailcall-optimization.

krzkaczor avatar krzkaczor commented on June 23, 2024

@dakotamurphyucf Seems reasonable but I would need to think more about this issue. The reason that it's not implemented is not that it's impossible but rather it's just complicated 😆

It would be great if you could find the original discussion regarding buggy TCOs in babel@5 and see what kind of issues people had there. (there's a link in readme but I think it's dead now)

from babel-plugin-tailcall-optimization.

dakotamurphyucf avatar dakotamurphyucf commented on June 23, 2024

@krzkaczor yea I have looked everywhere for it and can't seem to find it. I am going to mess around and try and implement the logic I mentioned. Unfortunately I am not that familiar with babel plugin development so I imagine what I proposed is easier said then done 😆

I imagine the issues they were having was primarily related to variable references. I know safari figured out a way to implement TCO to spec so it definitely must be doable. I would love to be a part of solving this, this plug-in is great! Such a time-saver in place of having to deconstruct functions for production code lol

from babel-plugin-tailcall-optimization.

dakotamurphyucf avatar dakotamurphyucf commented on June 23, 2024

@krzkaczor I think I found relevant threads. babel/babel#256.
Looks like a lot of the issues stem from debugging concerns related to stack trace. Also it seems they are waiting on this proposal https://github.com/tc39/proposal-ptc-syntax.

from babel-plugin-tailcall-optimization.

krzkaczor avatar krzkaczor commented on June 23, 2024

@dakotamurphyucf oh wow, ptc syntax is really interesting 👍

I would be really great if you could implement your idea as discussed. I would just prefer if it would be OPT-IN (as option in config or something?), since not breaking existing code is an absolute priority. If it works well for some time we can make it default :)

from babel-plugin-tailcall-optimization.

dakotamurphyucf avatar dakotamurphyucf commented on June 23, 2024

@krzkaczor yea I agree with it being OPT-IN. I'll start working on it and create a pull-request.

from babel-plugin-tailcall-optimization.

xtuc avatar xtuc commented on June 23, 2024

Good idea! I'm not a TCO expert btw.

What prevents you from doing:

-   const  val = b.find((state => s => s.min < state['min'])(_state))
+   const  val = b.find(s => s.min < _state["min"])

We should be able to detect a closure in a closure and throw, I guess shadowing and scoping will become complicated. Just to avoid breaking the state for outer functions.

I know safari figured out a way to implement TCO to spec so it definitely must be doable

I wouldn't rely on this assumption. The heursistic is quite complex and they spent a lots of hours in it.

from babel-plugin-tailcall-optimization.

xtuc avatar xtuc commented on June 23, 2024

We should be able to detect a closure in a closure and throw, I guess shadowing and scoping will become complicated. Just to avoid breaking the state for outer functions.

I was wondering about:

function someMethod(min, b) {
  function a() {
   var min;
   min = 5;
   function b() {
      var min;
      min = 9;
   }

  // maybe b();
 }

   a();
   ///...
  return someCondition ? someMethod(val.min, someStatementOf(val)) : val.min
}

The two min declarations should end up overwritting themself in the state.

from babel-plugin-tailcall-optimization.

Related Issues (15)

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.