Questions tagged [indirection]

Any of various programming concepts related to the level of abstraction applied to a particular problem, algorithm or scenario. Examples may include substituting higher-level programming constructs where previously lower-level constructs were previously applied.

Indirection

Any of various programming concepts related to the level of abstraction applied to a particular problem, circumstance, algorithm or knowledge domain.

160 questions
3
votes
3 answers

What is the purpose of passing props to a React search bar?

I'm learning to Think in React, but don't understand why the SearchBar in the example needs to have value={this.props.filterText} and checked={this.props.inStockOnly}, the jsFiddle still works without them and it doesn't make sense for props to be…
stackjlei
  • 9,485
  • 18
  • 65
  • 113
3
votes
1 answer

What is the cost of pointer indirection versus allocating on the stack?

I have a draw method that will be called repeatedly (every frame...). Inside this method I have a handful of locally defined variables (roughly 20). I am considering putting these inside a structure, and passing a pointer to that structure as a…
LunchMarble
  • 5,079
  • 9
  • 64
  • 94
2
votes
1 answer

How two concatenate environment variables names in powershell

Say I have the following environment variables: a = Poke b = mon Pokemon= Feraligatr I want to be able to concatenate a and b environment variables to get the variable name Pokemon and the get Pokemon value like $($env:ab) or…
Retrosec6
  • 169
  • 11
2
votes
0 answers

Passing unique_ptr compiles to more indirections than passing raw or even wrapped pointer

I'm using godbolt.org to compare the compiled code, with -O3 as optimization flag. I tried a few things, as currently I'm trying to optimize some code, and so I came to this: So it comes out that passing unique_ptr requires more indirections than…
2
votes
2 answers

How to use delayed expansion on a variable like %%a or %1?

I'm trying to make a batch file I call from another batch file, but the variables don't work, all the results are "a", while the expected result would be option1=a, option2=b, etc. Here's the code to demonstrate the issue: call temp.bat a b c d e f…
2
votes
2 answers

Create an incrementing variable from 2 variables in PowerShell

OK, First I consider myself a newbie and have much to learn about PowerShell and this is my first post ever. I am trying to loop through some data and put it into a custom object and put them into separate arrays for later use. The issue is that I…
2
votes
1 answer

Inserting for loop's variable into another variable names

I'm trying to simplify a Windows interface script that my colleague did in which he used a lot of if-loops which I think can be further shortened using for-loops. Basically we have a couple sets of computers that ranged from 4 - 12 per set & we…
talexeh
  • 23
  • 5
2
votes
1 answer

Validating numbered variables in PowerShell

I am writing a script to generate a text file, based on user-provided variable values. The variables are provided through another application and they come into Windows as environmental variables. So I have the following: [hashtable]$variables =…
StackExchangeGuy
  • 741
  • 16
  • 36
2
votes
2 answers

How do I use a method to change a pointer?

I'm working on an iPhone app using objective C. I've got class A, which creates an NSMutableArray pointer called "list". But, in class A, I never create an object for it to point to. Instead, I call a class method in class B, to get some data…
Adam
  • 125
  • 4
2
votes
3 answers

indirection cost ~ 3x of float multiplication, really? (with demo)

I just found that indirection cost around 3 times of float multiplication! Is it what to be expected? Is my test wrong? Background After I read How much does pointer indirection affect efficiency?, I become panic about indirection cost. …
javaLover
  • 6,347
  • 2
  • 22
  • 67
2
votes
0 answers

cost of (address) indirection to the same address many times (used in iterator)

If I use indirection a lot, but the target has the same address, will the cost of indirection become near-zero? Example :- class C{ public: int database[100000]; //other functions }; class B{ public: C* c=nullptr; }; First…
javaLover
  • 6,347
  • 2
  • 22
  • 67
2
votes
2 answers

What's a reason for this function to exist?

In encoding/json the un-exported reflectValue function passes on all its arguments to another function. func(e *encodeState) reflectValue(v reflect.Value, opts encOpts) { valueEncoder(v)(e, v, opts) } The call to valueEncoder…
Sridhar
  • 2,416
  • 1
  • 26
  • 35
2
votes
1 answer

How to eval a field name contained in another field in an Access Query?

I need to create a long list of complex strings, containing the data of different fields in different places to create explanatory reports. The only way I conceived, in Access 2010, is to save text parts in a table, together with field names to be…
Zigo
  • 41
  • 5
2
votes
4 answers

Have you come across any reason for three levels of indirection?

Just flicking through one of my favourite books (Ellen Ullman's The Bug) and there is a small bit where one programmer confronts another over three levels of indirection: ***object_array = ***winarray; I get the idea of double indirection - a way…
Abizern
  • 146,289
  • 39
  • 203
  • 257
2
votes
5 answers

Why is my multi-dimensional dynamic allocation in C not working?

I have been trying to figure out the problem with my allocation and use of a multidimensional dynamically allocated array in C. I'd really appreciate any help. I've tried two approaches. The first: cdr = (double ***) malloc(NUM_REGIONS *…
Mark
  • 21
  • 3
1 2
3
10 11