nested-function Questions

3

Solved

I was given this extensive PowerShell script from a major/reputable corporation which was supposed to work flawlessly. Well, it didn't. The script is composed of numerous nested functions with lots...
Foist asked 23/4, 2015 at 18:43

9

Solved

Those familiar with x86 assembly programming are very used to the typical function prologue / epilogue: push ebp ; Save old frame pointer. mov ebp, esp ; Point frame pointer to top-of-stack. sub e...

3

How would I declare a nested function in VB.NET? For example, I want to do something like this: Function one() Function two() End Function End Function However, this statement is invalid in VB...
Minority asked 9/1, 2011 at 9:3

6

Solved

I am trying to set up a function to reformat a string that will later be concatenated. An example string would look like this: Standard_H2_W1_Launch_123x456_S_40K_AB Though sometimes the "S" doe...
Mckelvey asked 11/3, 2014 at 0:13

12

Solved

In JavaScript nested functions are very useful: closures, private methods and what have you.. What are nested PHP functions for? Does anyone use them and what for? Here's a small investigation I ...
Begotten asked 6/1, 2009 at 9:56

10

Solved

What does nonlocal do in Python 3.x? To close debugging questions where OP needs nonlocal and doesn't realize it, please use Is it possible to modify variable in python that is in outer, but not g...
Shana asked 11/8, 2009 at 17:36

7

Solved

What benefit or implications could we get with Python code like this: class some_class(parent_class): def doOp(self, x, y): def add(x, y): return x + y return add(x, y) I found this in an open...
Pasqualepasqueflower asked 19/10, 2009 at 14:40

1

Solved

For example, public int DoSomething(in SomeType something){ int local(){ return something.anInt; } return local(); } Why does the compiler issue an error that the something variable cannot be ...
Influential asked 14/8, 2022 at 14:34

10

Solved

I have seen and used nested functions in Python, and they match the definition of a closure. So why are they called "nested functions" instead of "closures"? Are nested function...
Chair asked 26/10, 2010 at 3:11

1

Solved

I'm new to Rust and have been looking through the source code a bit, and found this: #[stable(feature = "fs_read_write_bytes", since = "1.26.0")] pub fn write<P: AsRef<Pat...
Clifford asked 15/5, 2022 at 6:48

2

Solved

I am developing an application in C / Objective-C (No C++ please, I already have a solution there), and I came across an interesting use case. Because clang does not support nested functions, my ...

8

Solved

I got a piece of code for javascript which I just do not understand: function dmy(d) { function pad2(n) { return (n < 10) ? '0' + n : n; } return pad2(d.getUTCDate()) + '/' + pad2(d.getUT...
Dillingham asked 3/9, 2011 at 20:16

5

Solved

Can anyone explain why 0's and 1's are printed and not anything else? Thank you! func makeFunction(name string) func() { fmt.Println("00000") return func() { makeFunction2("abcef") } } fun...
Congratulation asked 16/1, 2018 at 21:5

11

Solved

I have the following piece of code: function initValidation() { // irrelevant code here function validate(_block){ // code here } } Is there any way I can call the validate() function outsid...
Moa asked 11/1, 2012 at 10:39

4

Solved

I have a simple context that sets some value that it get from backend, pseudo code: export const FooContext = createContext(); export function Foo(props) { const [value, setValue] = useState(null...
Trypsin asked 8/10, 2020 at 9:45

2

Solved

def make_functions(): flist = [] for i in [1, 2, 3]: def print_i(): print(i) flist.append(print_i) return flist functions = make_functions() for f in functions: f() The output of this co...
Gladysglagolitic asked 23/9, 2020 at 7:10

4

Solved

Okay, bear with me on this, I know it's going to look horribly convoluted, but please help me understand what's happening. from functools import partial class Cage(object): def __init__(self, an...
Cyb asked 14/9, 2012 at 11:28

3

Solved

I have this code: function test() function awesome() print("im awesome!") end function notawesome() print("im not awesome.") end function notevenawesome() print("im not even awesome...")...
Swale asked 1/4, 2018 at 17:47

12

Let's say that a function A is required only by function B, should A be defined inside B? Simple example. Two methods, one called from another: def method_a(arg): some_data = method_b(arg) ...
Indigestible asked 28/1, 2011 at 18:23

3

As far as I know, there are three ways to define functions in JavaScript. 1. Declaration function handleEvent(e) {} 2. Assignment var handleEvent = function(e) {} 3. Arrow var handleEvent =...
Lheureux asked 3/8, 2019 at 9:22

3

Solved

I'm trying to clean up code by stripping parameters from a function within a private scope, like this: Function complicatedFunction(x as Double, param1 as Double, param2 as Double) ... End Functi...
Assessor asked 12/5, 2014 at 17:48

8

Solved

In C the following code works in gcc. int foo( int foo_var ) { /*code*/ int bar( int bar_var ) { /*code*/ return bar_var; } return bar(foo_var); } How can I achieve the same functionalit...
Agnesagnese asked 18/3, 2011 at 18:4

11

Solved

I know that nested functions are not part of the standard C, but since they're present in gcc (and the fact that gcc is the only compiler i care about), i tend to use them quite often. Is th...
Controversy asked 28/5, 2010 at 13:22

2

Solved

With closures I usually append [weak self] onto my capture list and then do a null check on self: func myInstanceMethod() { let myClosure = { [weak self] (result : Bool) in if let this = self ...

3

Solved

I'm just learning some Swift and I've come across the section that talks about nesting functions: Functions can be nested. Nested functions have access to variables that were declared in the out...

© 2022 - 2025 — McMap. All rights reserved.