Questions tagged [thunk]

A parameterless closure (functional programming) or a function generated by a compiler to aid runtime linking with a dynamic library function.

  • In functional programming, a thunk is an anonymous and parameterless function (closure), used to pass lazily evaluated expressions.
  • In C++, a thunk is a compiler generated function which optimizes virtual function calls.
  • On systems which support dynamic linking, a thunk is often automatically inserted to provide a place for the runtime linker to insert code for invoking the actual implementation found in a library.
184 questions
6
votes
1 answer

thunk for @escaping @callee_guaranteed (@guaranteed UIAlertAction) -> ()

I've following crash which occurs in live app, I can't reproduce it during development. Log is from Crashlytics. I can't figure out the reason for crash and how to fix. Any help? Crash Log Crashed: com.apple.main-thread 0 MyApp …
Raymond
  • 1,108
  • 13
  • 32
6
votes
1 answer

why foldl is not short circuiting with andFn function?

My understanding is that foldl and foldr executes like : foldl f a [1..30] => (f (f (f ... (f a 1) 2) 3) ... 30) and foldr f a [1..30] => (f 1 (f 2 (f 3 (f ....(f 30 a)))))..) so.. foldr (&&) False (repeat False) can shortciruit as outermost f sees…
Ashish Negi
  • 5,193
  • 8
  • 51
  • 95
6
votes
4 answers

How do I serialize or save to a file a Thunk?

In Haskell, you can have infinite lists, because it doesn't completely compute them, it uses thunks. I am wondering if there is a way to serialize or otherwise save to a file a piece of data's thunk. For example let us say you have a list [0..].…
PyRulez
  • 10,513
  • 10
  • 42
  • 87
5
votes
4 answers

Module not found: can't resolve' redux-thunk ' error I have tried the solutions but it does not happen.What is the solution?

I tried all the commands for redux but it doesn't work:how do you think the solution is. These are the commands I tried yarn add react-redux yarn add reduxjs / Redux-thunk#master npm install --save Redux react-redux npm install redux -- save npm i…
5
votes
1 answer

Thunk and ATL Thunk?

Can someone explain to me what a Thunk is? and an ATL Thunk? I know a thunk has something to do with the vtbl and execution of code to find the right function pointer. Am I right?
Tony The Lion
  • 61,704
  • 67
  • 242
  • 415
5
votes
1 answer

Does VC conform to the standard with respect to warning C4407?

The following source generates warning C4407 in VC and the compiler does indeed produce the incorrect code. struct A1 { int a1; }; struct A2 { int a2; }; struct B: A1, A2 { void f() { std::cout << this << '\n'; } }; int…
Lingxi
  • 14,579
  • 2
  • 37
  • 93
5
votes
2 answers

How do non-static callbacks work from native code?

It's a bit odd asking this question, because I have code that seems like it shouldn't work, but it does, and although I'm not complaining, I'd like to confirm why? LOL Simply, I have a C++ native DLL (no CLR/managed support at all) that takes a…
James Wilkins
  • 6,836
  • 3
  • 48
  • 73
5
votes
1 answer

What is the purpose of thunk file generated by matlab?

When calling external C library (DLL) from matlab, it seems that matlab will first try to generate a thunk file named as filename_thunk_pcwinXX.dll (where XX is either 32 or 64 depend on the OS) in a temp directory. In matlab docs, it mentions that…
user0002128
  • 2,785
  • 2
  • 23
  • 40
5
votes
2 answers

How to thunk a function in x86 and x64? (Like std::bind in C++, but dynamic)

How do I thunk an arbitrary function with an arbitrary (fixed) number of arguments, on x86 and x64? (I don't need floating-point, SSE, or the like. The arguments are all integers or pointers.)
user541686
  • 205,094
  • 128
  • 528
  • 886
4
votes
1 answer

How to pass a method as callback to a Windows API call (Follow-up)?

This post is a follow-up of a related question posted here by Ran. The accepted answer sticks to the use of the usual a plain old function. This excerpt particularly catch my attention: An instance method has an extra, implicit, parameter…
menjaraz
  • 7,551
  • 4
  • 41
  • 81
4
votes
2 answers

How to get updated state from Redux store using redux-toolkit after component has already rendered?

The functionality I am looking for is that of an e-commerce website. A click on the add-to-cart button adds product to cart. I am able to successfully achieve that by dispatching an action. Post that I want to grab the state of the updated cart…
4
votes
1 answer

React Redux app - complex init action composition executes final promise before the others are done

I'm working on an app which has to manage a large amount of data. In the init process several api calls must be done while the user sees a loading bar. Here is my init action: export function init(key) { return (dispatch, getState) => { //…
Gordon Freeman
  • 3,260
  • 1
  • 22
  • 42
4
votes
3 answers

Undefined reference to virtual thunk

I got an error saying undefined reference to 'virtual thunk to myClass::myFunction' For a library i'm trying to create. Here's my code : myClass.cpp : #include "myClass.h" void myClass::myFunction() {} myClass::~myClass()…
user2069871
3
votes
1 answer

Why are virtual thunks necessary?

This question is about a (possible) implementation for virtual function calls (which I believe it is used by gcc). Consider the following scenarios: class F inherits from class D (and maybe others) which inherits from class B (not virtually). D…
user42768
  • 1,951
  • 11
  • 22
3
votes
2 answers

ESLint Airbnb ES6 and Redux Async Action Unexpected block statement surrounding arrow body

What am I doing wrong? I have like three other async actions that have the same issue and can't fix it.
Pedro Costa Neves
  • 463
  • 1
  • 5
  • 15
1
2
3
12 13