Comments (1)
Description from #77
Trampoline is often used to emulate tail recursion. The idea is to have some step code that can be trampolined itself to emulate recursion. The difference with standard recursion would be that there is no need to rewind the whole stack when we reach the end of the stack, since the first value returned that is not a trampoline would be directly returned as the overall result value for the whole function chain. That means Trampoline emulates what tail recursion does.
There are languages that do not have tailrec modifier that use Trampoline to emulate the same behavior. But Trampoline is also useful for languages that also have trampolines out of the box:
"As long as you use tail recursion with one function everything is fine as the compiler will optimize it for you and transform it in a loop, issues come when you are trying to use tail recursive calls between two functions or when you donβt have a tail recursive call."
Trampolines are stack safe, since they do not need to maintain a function call stack (since they don't need to rewind it). So trampolines are useful also when you don't want to blow your stack up for too long recursive operations.
from arrow.
Related Issues (20)
- NonEmptyList.distinct() throws NPE for nullable types HOT 3
- tupleOf with overloads ["Request"] HOT 2
- Circuit breaker `maxFailures` documentation inaccurate
- ["Request"] better stack traces when tracing `withError`
- arrow-stack does not specify version of "io.arrow-kt:arrow-optics-ksp-plugin" HOT 2
- Retrofit+Arrow to Ktor Client+Arrow migration HOT 8
- Road to 1.2.3 HOT 7
- ["Request"] DefaultedMap HOT 5
- @optics generates bad code for sealed hierarchies with changing property nullability
- @optics generates bad code when dealing with generic properties in a sealed hierarchy
- @optics generates bad code when dealing with nested generic sealed hierarchies
- ["Documentation"] Ior Knit examples not rendering properly
- autoCloseScope: the order of close method calls is not the same as `AutoCloseable.use` HOT 2
- Tracing reports a swallowed CancellationException warning HOT 7
- Fold restriction not allowing any Function<*> to be returned is too strict HOT 20
- ["Request"] Raise DSL for working with nonEmptyLists HOT 3
- @optics generates bad code for data class with generic named 'S' HOT 1
- ["Bug"] Arrow core 1.2.4 not compatible with Kotlin WASM JS HOT 3
- ["Request"] Annotate Raise interface with @RaiseDSL HOT 2
- Discussion around the Gradle setup HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arrow.