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
0
votes
3 answers

Pointlessly trying to compare rsp across a call without using registers

I would like to write a small thunk which will call an underlying function and then compare the value of rsp before and after the call. Critically, this code shouldn't clobber any registers. The obvious implementation is to simply push rsp before…
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
0
votes
1 answer

Using thunk to conditionally perform async does not execute twice

I'm following along with the Kyle Simpson Rethinking Asynchronous JavaScript video course and am confused about how his thunk pattern is using closures. The code is like this: function ajax(url, cb) { $.ajax({ url: `text/${url}`, type: 'GET',…
1252748
  • 14,597
  • 32
  • 109
  • 229
0
votes
1 answer

Fetch on react / redux not work properly

I am new in react, and try to make my first project using such features: react, redux, react-router, redux-thunk. I am fetching data from url with json. It works fine on powerfull pc, on wicker it will not work becouse as i understud, it is starts…
Ivan Kaduk
  • 60
  • 1
  • 7
0
votes
1 answer

Understanding 'sprint' after evaluating a polymorphic expression

Given: λ: let x = 1 + 2 I run sprint to print its value: λ: :sprint x x = _ As expected, it's unevaluated. But, after evaluating x: λ: x 3 sprint still outputs _, i.e. unevaluated: λ: :sprint x x = _ Why is that?
Kevin Meredith
  • 41,036
  • 63
  • 209
  • 384
0
votes
2 answers

Incorrect vtable layout for class exported by DLL: request for clarification regarding headers and vtable construction

Although the problem at hand is solved, it has me a little confused as to what data is used to construct the vtables for a class and where the layout for the vtable is stored. If anyone can provide clarification or point me towards some information…
acanaday
  • 400
  • 1
  • 11
0
votes
1 answer

Scala Lifting to a thunk

I have a function that wraps the result of another function in a Promise. I wanted to promote this into a lift function so that I could sort of re-use it elsewhere. Here are the original definitions: val abc = Promise[MyType]() try { val suck =…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

Unable to use thunkify npm package properly

There is following signature of the function: function hashPassword(password, callback){} I want to call it within co generator function, so I try wrapping it with thunkify like this: var checkPassword = thunk(user.checkPassword); var isValid =…
Yevgen Safronov
  • 3,977
  • 1
  • 27
  • 38
0
votes
1 answer

Koa and Twitter - "Thunking" does not work

I've gotten some third party asynchronous functions to work with Koa through thunking, either by wrapping the function like so: var thunkedFunction = function(params) { return function(callback) { originalFunction(params, callback) }; ) or using the…
arilaan
  • 384
  • 2
  • 17
0
votes
2 answers

About strictness in haskell

I've created the following Haskell prime function (within ghci): let pi :: Int -> Int -> Int; pi 1 _ = 2; pi x y = if all (/=0) (map (rem y) [pi z 2| z <- [1..(x-1)]]) then y else pi x (y+1); Please don't mind the second/memoized argument (it…
dumb0
  • 337
  • 1
  • 8
0
votes
1 answer

Does scala has a class for lazy thunks that are evaluated once or never?

Something as simple class Thunk[+A](body: => A) { lazy val result: A = body; } Is it defined somewhere? Or perhaps a slightly more sohpisticated class Thunk[+A](body: => A) { private[this] var evaluatedInternal = false; lazy val result: A =…
Petr
  • 62,528
  • 13
  • 153
  • 317
0
votes
1 answer

IAT Hooking ExitProcess on own process

I`d like to ask a question regarding IAT hooking on my own process . I am currently trying to hook ExitProcess so it would run a certain function before any ExitProcess call, and I am facing some troubles . I am traversing the PE at runtime, going…
Danny Shemesh
  • 67
  • 1
  • 9
-1
votes
3 answers

Are there any other queues in the standard library?

I want to queue lambda : Popen(.....) To call/wait at a later time. Then add some more to paused Popens to the queue, then consume them again and so on. The main Queue module cares a lot about synchronization and this makes the api feel a bit…
Roman A. Taycher
  • 18,619
  • 19
  • 86
  • 141
-1
votes
1 answer

dispatch(fetchPosts()) give empty state

Here is all ok, response.data is array: export const fetchPosts = createAsyncThunk('posts/fetchPosts', async () => { const response = await axios.get('https://640114a00a2a1afebee5c77d.mockapi.io/post1') console.log(response) return…
b2ok
  • 544
  • 6
  • 13
-1
votes
1 answer

Then works but await doesn't work with Promise from thunk action

I'm using redux/toolkit and have a thunk action to request an update API then do navigation. I try to return a promise so that I can wait for the operation to complete before navigation. The issue begins when after API calls. If I use then the…
pucca garu
  • 97
  • 9
-1
votes
1 answer

Receiving 404 Error from Axios post request to MongoDB

I am working on a MERN stack project for a proof-of-concept and am creating a wall where I can add posts from a form. The form accepts name, tags, title, and a message along with an image. Upon clicking submit, Axios gives me a 404 error in the…
1 2 3
12
13