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
2
votes
2 answers

How to make controlled input component in Redux?

I'm implementing movie search functionality using the moviedb api. I have implemented in React only but I want to do it in Redux. Here is my approach in React. Header.js import React, { Component } from "react" import { Navbar, Form, FormControl }…
2
votes
2 answers

Why "State" is empty after action is dispatched?

I am working on Log in authentication. After user logged in successfully I want to show log out button based on token value in the state. User gets logged in successfully But actually state is empty and have no values which are passed from express…
2
votes
0 answers

Use of thunks, trampolines and continuation passing in python

I came to know about the concept of Tail Call Optimization(TCO) from this blog: Sing Me A Song of Stack Overflow: A Musical Tail Call Optimization. Going into this concept(or "feature" or "optimization technique"), I came to know that using TCO in…
Sanip
  • 1,772
  • 1
  • 14
  • 29
2
votes
1 answer

Why thunks must be explicitly forced when you define Streams iin Scala?

I am reading a Scala textbook regarding Streams sealed trait Stream[+A] case object Empty extends Stream[Nothing] case class Cons[+A](h: () => A, t: () => Stream[A]) extends Stream[A] The textbook reads "Due to technical limitations, these are…
zell
  • 9,830
  • 10
  • 62
  • 115
2
votes
1 answer

Resolving async function in action creator

I'm trying to resolve this async call in my action creator before the state is updated. I tried to implement redux thunk but I am fairly new to it and angular4+ as a whole. Here is what my action creators look like: @Injectable() export class…
Joe Nixon
  • 105
  • 5
2
votes
1 answer

why my redux state not updating

state not updating.when action is dispatched the state should update to isAuthenticated to true..but the state not updating..redux returning the initial state not the updated state. export function setCurrentUser(user) { console.log(user); …
PrudhviD
  • 56
  • 1
  • 2
  • 7
2
votes
2 answers

Pass by name implementation in C

How can I calculate the value of the arithmetic expression ^2 + 3i − 1 that is dependent on the index i by using pass-by-name mechanism in C language 9 ∑ i^2 + 3i − 1 =0 through a call to a sum procedure with argument(s) passed by name Pass by name…
2
votes
1 answer

Why the output is “In foo, a = 7”?

void foo(int a) { printf ("In foo, a = %d\n", a); } unsigned char code[9]; * ((DWORD *) &code[0]) = 0x042444FF; /* inc dword ptr [esp+4] */ code[4] = 0xe9; /* JMP */ * ((DWORD *) &code[5]) = (DWORD) &foo - (DWORD) &code[0] - 9;…
COMer
  • 5,091
  • 4
  • 22
  • 20
2
votes
1 answer

Swift - App store reject - partial apply forwarder for reabstraction thunk helper

My app is getting rejected by Apple. It works perfectly fine as an ADHOC built but crashes when Apple does its testing. Any help will be greatly appreciated. The error im getting is (crash log) : 12 nFocus Admin 0x100057f0c…
2
votes
3 answers

Mac gcc non-virtual thunk error

I'm getting these non-virtual thunk errors only in the Deployment build of my app. It uses a private framework called Lgi. Building on 10.5.8 using XCode 3.1.4 (latest for leopard?) The error looks like this: Ld…
fret
  • 1,542
  • 21
  • 36
2
votes
1 answer

Are there multiple ways of writing a thunk in SML?

Basic noob question: I have data I need to evaluate lazily, the most common way of doing this is by making a thunks; the way I'm used to do it is like this: fun someFunc () = let fun myThunk () = 2 + 2 in (* body *) end But every…
Electric Coffee
  • 11,733
  • 9
  • 70
  • 131
2
votes
2 answers

How can I get more information about symbol by it's address in memory

I'm trying to get the symbol name by its address in memory. I use int dladdr(void *addr, Dl_info *info) function from dlfcn.h to get the information: typedef struct { const char *dli_fname; /* Pathname of shared object that …
linuxbuild
  • 15,843
  • 6
  • 60
  • 87
2
votes
0 answers

"non-virtual thunk to ...." error in iOs

In my iPhone app i am getting the following error: "non-virtual thunk to metaio::UnifeyeMobileiPhone::UnifeyeMobileiPhone()" and the point where the error occured is: - (void)dealloc { // Tear down context. if ([EAGLContext currentContext]…
Mithuzz
  • 1,091
  • 14
  • 43
1
vote
1 answer

Please explain coding for "thunks."

I have the following code I've tried from the book. ;pg 51 "The Scheme Programming Language" by R. Kent Dybvig" (define lazy (lambda (t) ;so lazy accepts argument t (let ([val #f] [flag #f]) ;isn't val <- #f (& flag <-…
Trenton J
  • 25
  • 3
1
vote
1 answer

How does action creator which is a thunk receive a store's dispatch method?

I am learning redux and there is one thing puzzling me regarding the internal logic - how does a thunk receive dispatch as argument if a thunk is an argument to dispatch and not vice versa? Here is a sample code: I am creating an action creator…
bakrall
  • 465
  • 7
  • 21