Why are they called thunks? #4
-
It seems like thunks are a core piece of Bass:
Curious why they're called thunks? As a newbie functional programmer, I'm familiar with thunks only in programming languages where you have something like: function add(one) {
return function(two) {
return one + two
}
}
add(1)(2) Is it the same concept? Where you have "thunk commands" like: function pull(repo) {
return function do() {
// actually pull
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Bass thunks have the following properties:
Note that these properties assume thunks are hermetic, i.e. they are are used as leverage to guide users towards hermetic builds. These properties align with a 0-arity pure function, which Haskell calls a thunk, so I did too. I believe the most general definition of thunk is just being a 0-arity function, per Wikipedia: // 'thunk' is a function that takes no arguments and, when invoked, performs a potentially expensive
// operation (computing a square root, in this example) and/or causes some side-effect to occur
const thunk = () => hypot(3, 4); Using the same term for functions and commands running in containers is definitely a bit of a stretch, but it seemed worth drawing a parallel to indicate how prominent thunks are in Bass. (Way, way more common than 0-arity functions.) I'm willing to change it if folks find it too confusing, but any new name would have to also be fun to say. 😁 |
Beta Was this translation helpful? Give feedback.
Bass thunks have the following properties:
Note that these properties assume thunks are hermetic, i.e. they are are used as leverage to guide users towards hermetic builds.
These properties align with a 0-arity pure function, which Haskell calls a thunk, so I did too. I believe the most general definition of thunk is ju…