-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constant stack usage #47
Comments
I don't think that's within the intended uses: if you want to compose pipelines you'll be using |
I might agree with you @jasmith79 if there was a builtin I'm all for a built-in though. See fantasyland/ECMAScript-proposals#1
I haven't suggested this usage. I did mention composing functions with other composed functions. |
If I understand correctly, exclaim(capitalize(doubleSay("hello"))) works like let _tmp = "hello"
_tmp = doubleSay(_tmp)
_tmp = capitalize(_tmp)
_tmp = exclaim(_tmp)
_tmp Therefore there is no nested stack frame? |
@dtinth you're right. For some reason I was thinking the behavior was the same as how some (x => exclaim((x => capitalize((x => doubleSay(x))(x)))(x)))('hello') which exclaim(capitalize(doubleSay("hello"))) does not. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
The current proposal desugars
to
If I want to reuse this pipeline I can write
Now I get reuse, but I'm allocating three stack frames. This isn't a big deal unless I want to compose
sayItAgainLouder
with some other functions.A simple alternative desugaring
This decreases stack usage, but I imagine at the cost of speed.
It would be useful if this proposal required the compiler to maintain constant stack usage through either some sort of stream fusion or stack frame reuse.
The text was updated successfully, but these errors were encountered: