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
1
vote
2 answers

What does asterisk before brackets on object creation mean in C++?

I was reading an example of a hash table implementation in C++ from a website and saw this. private: HashEntry **table; public: HashMap() { table = new HashEntry*[TABLE_SIZE]; for (int i = 0; i < TABLE_SIZE; i++) …
James4701
  • 63
  • 1
  • 7
1
vote
5 answers

Performance of repetitive indirection

I find myself debating whether I want to write like Code 1 vs Code 2. In my opinion, Code 1 looks cleaner, but in theory, can I expect a performance penalty due to its extra indirections compared to Code 2? Are there any relevant compiler…
Agrim Pathak
  • 3,047
  • 4
  • 27
  • 43
1
vote
4 answers

Accessing variables indirectly

Within my code (javascript in a firefox extension), i have a list of some variables, like this: var myApp = { var1: true, var2: false, var3: true, var4: false }; I want to access these variables to get their value indirectly using a…
cicada
  • 13
  • 2
  • 4
1
vote
3 answers

Direct invocation vs indirect invocation in C

I am new to C and I was reading about how pointers "point" to the address of another variable. So I have tried indirect invocation and direct invocation and received the same results (as any C/C++ developer could have predicted). This is what I…
Mohit Deshpande
  • 53,877
  • 76
  • 193
  • 251
1
vote
3 answers

Purpose of dereferencing a pointer as a parameter in C

I recently came along this line of code: CustomData_em_free_block(&em->vdata, &eve->data); And I thought, isn't: a->b just syntactic sugar for: (*a).b With that in mind, this line could be re-written as: CustomData_em_free_block(&(*em).vdata,…
Leif Andersen
  • 21,580
  • 20
  • 67
  • 100
1
vote
1 answer

ALET macro and use of indirection

In chapter 6 of "Let Over Lambda" I found anaphoric macro called alet. It works like let, but especially useful when the last form of alet body is a lambda expression, since it allows using of the lambda expression before it actually occurs in the…
Mark Karpov
  • 7,499
  • 2
  • 27
  • 62
1
vote
2 answers

Assign value to a variable in unix dynamically - variable indirection

HOST_NAME_="localhost:8080" HOST_NAME_stg="stg.com:8080" HOST_NAME_qa="qa.com:8080" HOST_NAME=${!"HOST_NAME_$1"} echo -n ${HOST_NAME} I get the error bad substitution.But I want stg.com:8080 to printed if the argument passed is stg.How do I do…
Abhijeet Kushe
  • 2,477
  • 3
  • 26
  • 39
1
vote
2 answers

Void pointers pretending to be void double pointers

I've been doing some thinking. I haven't found anything directly answering this question, but I think I know the answer; I just want some input from some more experienced persons. Knowns: A void pointer points to just a memory address. It includes…
ciphermagi
  • 747
  • 3
  • 14
1
vote
1 answer

Bind XAML property indirectly

Imagine, I have a button and a binding:
1
vote
1 answer

Field indirection using reflection methods

Given: public class A { public int n; public int func(Object arg) {...} ... } public class B { private A myA; ... } private B myB; When using reflection on myB I get the field for myA; how can I access the members and methods of…
ilomambo
  • 8,290
  • 12
  • 57
  • 106
1
vote
1 answer

In R, how can I construct an anonymous list containing an element whose name is contained in a variable?

I would like to insert an element into a list in R. The problem is that I would like it to have a name contained within a variable. > list(c = 2) $c [1] 2 Makes sense. I obviously want a list item named 'c', containing 2. > a <- "b" > list(a =…
Keith Twombley
  • 1,666
  • 1
  • 17
  • 21
1
vote
2 answers

Illegal indirection in C++ templates

I got a template class and once it gets a string as a T and the other Para* as a T. I have overloaded << for Para. friend ostream& operator<< (ostream &wyjscie, Para const& ex){ wyjscie << "(" << ex.wrt << ", " << ex.liczbaWystapien <<")"<<…
Yoda
  • 17,363
  • 67
  • 204
  • 344
1
vote
2 answers

Indirection with linq : Change query expression "Select" according users parameters

I use a table "TLanguage" to record lable results of my site. I have 4 columns in this table: French, English, German and Spanish. In a MVC application I use this query: var req = (from TYP in context.TYP_TypeMission join ML in…
1
vote
6 answers

Accessing variables from a struct

How can we access variables of a structure? I have a struct: typedef struct { unsigned short a; unsigned shout b; } Display; and in my other class I have a method: int NewMethod(Display **display) { Display *disp=new Display(); *display…
Zeeshan Rang
  • 19,375
  • 28
  • 72
  • 100
0
votes
2 answers

C++ Indirection in accessing members from another member

Given the following example code: class Room { Room() : switch(*this) { } Lamp lamp; Switch switch; void TurnOn() { lamp.TurnOn(); } } class Switch { Switch(Room& room) : room(room) { } Room& room; void TurnOn() {…
Cookie
  • 12,004
  • 13
  • 54
  • 83