Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
2 answers
97 views

In a CGI script that processes arrays of strings the user can supply for each field whether to match a string there or not. If all user-specified criteria are fulfilled, the specific array should be ...
U. Windl's user avatar
  • 4,738
1 vote
1 answer
86 views

I was experimenting with closures in JavaScript and ran into something confusing. function outer() { let x = 10; return new Function("return x;"); } const fn = outer(); console.log(fn()); I ...
Prince verma's user avatar
2 votes
0 answers
103 views

Follow-up to: Detailed Explanation of Variable Capture in Closures Given that captured variables are implemented as fields in compiler-generated classes (as explained in the referenced answer), does ...
Jasper's user avatar
  • 39
5 votes
1 answer
75 views

I have the following code: fn test() -> (impl FnMut(&mut u8), impl FnMut(&mut u8)) { let a = |v: &mut u8| {*v = 0}; let b = move |v: &mut u8| { a(v); println!("{}&...
Nils Oskar Nuernbergk's user avatar
-2 votes
1 answer
71 views

I'm trying to set GLOBAL variable available across all modules of Node.js app. module.exports = app => { app.get('/config', async (req, res) => { ..... const { data } = await axios....
John Glabb's user avatar
  • 1,711
0 votes
0 answers
35 views

I'm debugging a performance regression in a hot code path and found that V8 is deoptimizing a function that uses closures in a monomorphic way. Here’s a simplified version of the pattern function ...
Bet Co's user avatar
  • 29
1 vote
1 answer
57 views

I'm curently exploring Lua (5.4.7) vm implementation, it's relatively simple but i can't figure our how return works in case of vararg functions. functions with fixed amount of params are quite simple,...
vanilla's user avatar
  • 145
0 votes
0 answers
52 views

I have following classes final class GroovyValidator { @Override public List<String> validate(String script) { final CompilerConfiguration config = new CompilerConfiguration(); ...
CoCumis's user avatar
  • 99
0 votes
1 answer
59 views

I'm trying to implement an array where items can occupy multiple slots (details not relevant to question). I have created a method that allows me to iterate over a range of items: pub fn get(&self,...
Fred's user avatar
  • 497
0 votes
0 answers
26 views

I have a data structure that needs to be read for tasks in multiple threads. Such a function looks like fn parallel_monte_carlo<T, R>( rngs: &mut [&mut R], initial_state: &[T]...
Dumbo's user avatar
  • 97
0 votes
2 answers
105 views

I'm working on a simple typing effect component in React using Framer Motion. Here's the code for my TypingText component TypingText.jsx import { motion } from 'framer-motion'; import React, { ...
thulhid's user avatar
1 vote
1 answer
91 views

I've been trying to understand closures better. I originally wrote fn main() { let mut x = 0; let f = || x += 1; call_me(f); f(); println!("x = {x}"); } fn call_me<F&...
Daniel Walker's user avatar
2 votes
1 answer
96 views

I originally thought T: 'a will restrict you form using T instance outside 'a because this exmaple reports an error: fn main() { let num; { let num1 = 10; // error: num1 doesn't live ...
Blackbird's user avatar
1 vote
2 answers
58 views

I have a question about Lua, closures and local variables. From my understanding, the loop variable in a numerical for-loop is implicitly local so I was expecting the following code to behave ...
Tobias Gierke's user avatar
1 vote
2 answers
95 views

In the following example, when the button is clicked, cb2 uses the memoized function. However, why doesn’t cb2 use the first render closures (countVal: 0)? function TestHook() { const [count, ...
2tuzi's user avatar
  • 66
2 votes
3 answers
78 views

Recently I am reading article related to useInterval, these code works fine: import React, { useState, useEffect, useRef } from "react"; import ReactDOM from "react-dom"; function ...
Kelsey Zhou's user avatar
0 votes
1 answer
32 views

I am writing tests that execute some of WordPress hooks / actions My hook example add_filter("asdasd", static function() { echo 'asdf'; }); It's complaining: This test executed code ...
Ruslan's user avatar
  • 86
0 votes
0 answers
21 views

Below is a Javascript code which attempts to parse some protobuf input data. 'use strict'; import protobuf from 'protobufjs'; const proto = protobuf.loadSync('gtfs-realtime.proto'); const ...
Michael Tsang's user avatar
0 votes
1 answer
92 views

I don't quite understand how closure works in Python. It behaves in an unexpected way that I can't comprehend. def A(): b = 1 def B(): b += 1 return b return B() print(A()) ...
user29008294's user avatar
0 votes
1 answer
114 views

In many languages closures are implemented using a structure in combination with a standard associated function (with a fixed name) which provides a method of making the object "callable". ...
user2138149's user avatar
  • 18.6k
-1 votes
1 answer
91 views

does anybody know where this is documented? All the places I searched for, closures require a in keyword after the capture list but there is a valid case in which you can just specify the capture list....
Alex's user avatar
  • 5,210
1 vote
1 answer
107 views

let mut x = 10; let mut closure: Box<dyn FnMut() -> i32> = Box::new(|| { println!("x = {}", x); x += 5; x }); let value1 = closure(); // x = 10 let value2 = closure(); /...
LetMeSoloRust's user avatar
1 vote
2 answers
891 views

In Xcode 16, I get this error, related to Swift 6. Capture of 'timer' with non-sendable type 'Timer' in a @Sendable closure; this is an error in the Swift 6 language mode How can I make this code ...
Daniele B's user avatar
  • 20.6k
0 votes
1 answer
96 views

I was considering the possibility of passing a closure that owns some thread-safe value, to a spawned thread. The thread would then be able to call something only knowing the signature, while the ...
goose_lake's user avatar
  • 1,627
1 vote
1 answer
100 views

I have a list component displaying objects with accordion elements. On expanding the accordion body, I use a (click)="addToArray(id)" method and have <edit-component *ngIf="idArray....
Benjamin's user avatar

1
2 3 4 5
182