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
1 answer

PHP: limitation of variable variables

In php I can do this: $class = 'Notes'; echo $class::message(); but it seems that from within a method, I can't do this: echo ($this->myClass)::message(); and also cannot do this: echo someFunctionThatReturnsClassName()::message(); Can anybody…
shealtiel
  • 8,020
  • 18
  • 50
  • 82
1
vote
2 answers

Quadruple pointer and memcpy() in C

First of all, I know triple and quadruple pointers are bad practice and are ugly, that's not the point of this question, I'm trying to understand how they work. I'm aware using a struct would be much better. I am trying to write a function that does…
Bernardo Meurer
  • 2,295
  • 5
  • 31
  • 52
1
vote
1 answer

Invoking a function indirectly, via a variable containing the function name

I'm importing a XML node to the variable XmlInstallNode and then dynamically building the function I want to call. Everything works great if I call the function directly by its name, but If called it in the invoke command using the $functionName,…
Nuno
  • 126
  • 2
  • 14
1
vote
2 answers

Batch: variable indirection: getting the value of a variable by dynamically constructed name

So when I run this code: @echo off setlocal enabledelayedexpansion set lstFolders= First Second set intCounter=0 for %%i in (!lstFolders!) do ( set /a intCounter += 1 set strFlder=%%i set strFolder!intCounter!=!strFlder! echo %%i …
jrwygal
  • 27
  • 4
1
vote
2 answers

Why is this macro generating a syntax error?

So this is my code: // Defines a tuple #define __WINDOW__RESOLUTION__ 500, 200 // Seperate the tuple #define __WINDOW__X__1(Width, Height) (Width) #define __WINDOW__Y__1(Width, Height) (Height) // Add another sort of indirection because my…
Brogramer
  • 75
  • 8
1
vote
1 answer

Memory address of list elements in cpython

I have heard that Python uses indirection to implement lists. That is, each element in a Python list is actually a pointer or reference to the place in memory where the actual element data (which could be an integer, string or any other data type)…
Ramkumar Hariharan
  • 967
  • 1
  • 7
  • 8
1
vote
2 answers

iterator Overload Member Selection vs Indirection Operator

So in the interest of creating a Minimal. Complete, Verifiable Example I have created a toy iterator here (I know it's not perfect, it's just for the purposes of asking a question): class foo : public iterator { …
Jonathan Mee
  • 37,899
  • 23
  • 129
  • 288
1
vote
1 answer

char* differs in levels of indirection from char(*)[100]

basically I am taking user input and using it to delete from a list, when this error has just been thrown. The code was working literally an hour ago so I don't know why Visual studio is now chucking a fit about it. char…
Jonno Williams
  • 107
  • 1
  • 1
  • 8
1
vote
1 answer

Understanding indirection

I'm currently working on cleaning up some shell scripts. While doing that, I came across something that looks like this: if [ ${#VARA} -eq 0 ] || [ ${#$VARB} -eq 0 ] || [ ${$VARC} -eq 0 ]; then ... fi As you can see, there are three different…
Matthew Herbst
  • 29,477
  • 23
  • 85
  • 128
1
vote
2 answers

Pointer indirection with an array

I'm trying to have three levels of pointer indirection with an additional pointer pointing to level two of the indirection. This is for a class, and I'm having some real issues. This is what I'm doing. int ***s = new int **[row]; *s = new int…
Mishap
  • 73
  • 1
  • 9
1
vote
4 answers

TOUGH: Dealing with deeply nested pointers in C++

I define this structure: struct s_molecule { std::string res_name; std::vector my_particles; std::vector my_bonds; std::vector my_angles; std::vector my_dihedrals; s_molecule& operator=(const…
1
vote
2 answers

Does R support indirect variable expansion or variable substitution?

In bash one can use an exclamation mark to use a variable's value as a variable. See explanation here. This is known as variable indirect expansion. This can be used to used to name a new variable using another variable in your code. I was wondering…
Gabriel Fair
  • 4,081
  • 5
  • 33
  • 54
1
vote
1 answer

GCC, linker-script: Variables that resolve to manually defined addresses?

I'll use a simple specific example to illustrate what I'm trying to do. file main.c: #include unsigned int X; int main() { printf("&X = 0x%zX\r\n", &X); return 0; } I want to know if it's possible (using a linker-script/gcc…
Zuzu Corneliu
  • 1,594
  • 2
  • 15
  • 27
1
vote
2 answers

Update array passed by reference with BASH

I would like to write a function that takes an array variable name and updates the contents. For example: ARRAY1=("test 1" "test 2" "test 3") toUpper ARRAY1 for arg in "${ARRAY1[@]}"; do echo "arg=$arg" done # output arg=TEST 1 arg=TEST…
dcompiled
  • 4,762
  • 6
  • 33
  • 36
1
vote
1 answer

creating environment variable with user-defined name - indirect variable expansion

I am trying to create an environment variable in bash script, user will input the name of environment variable to be created and will input its value as well. this is a hard coded way just to elaborate my question : #!/bin/bash echo Hello export…
Bramsh
  • 389
  • 1
  • 2
  • 14