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
2
votes
2 answers

Print multiple bash variables

I have the following script. #!/bin/bash d5=me d6=you d7=re for i in {5..7} do echo $"d$i" done This prints out d5 d6 d7 I'm looking to print me you re
Henry
  • 23
  • 3
2
votes
1 answer

How to get the keys and values of an associative array indirectly in Bash?

In Bash, given only a variable that contains the name of an associative array, $ declare -A dict=([abc]=125 [def]=456) $ dictvar="dict" how can we retrieve the keys and values of the associative array?
alexei
  • 2,031
  • 1
  • 26
  • 28
2
votes
2 answers

how to write a Bash function that confirms the value of an existing variable with a user

I have a large number of configuration variables for which I want users to issue confirmation of the values. So, there could be some variable specifying a run number in existence and I want the script to ask the user if the current value of the…
d3pd
  • 7,935
  • 24
  • 76
  • 127
2
votes
2 answers

How to dereference a double void pointer to an int pointer

I have a code that looks somewhat like this: int num = 5; int *ptr = # void **xptr = &ptr; printf ("values:%d\n",**(int *)xptr); Why can't i de-reference a void double pointer,which points to an int pointer ? The below two examples…
hmmm
  • 93
  • 2
  • 9
2
votes
2 answers

Explaining local -a 'xkeys=("${!'"$1"'[@]}")'

This code is given as a workaround for array indirection at bash-hackers.org wiki page as an example to get array length and indices indirectly. It's also mentioned in this Stackoverflow question. I would like to understand specifically why local -a…
amayem
  • 79
  • 6
2
votes
1 answer

JPA Transparent Indirection and Container Policies

Suppose I have the following simple Customer/Order implementation: A record of customers defined by a Customer class. Each customer can have multiple orders defined by an Order class. Drawing on the explanation of Transparent Indirection from here…
user3337410
  • 94
  • 1
  • 10
2
votes
2 answers

How to interpret user input as a variable name?

This one is kind of hard to explain. Consider variables all, first, last, and some: a="apple mcintosh" b="banana plantain" c="coconut cashew" all="$a $b $c" first="$a" last=$c" some="$a $c" Here is what I have: echo "What do you want to…
octosquidopus
  • 3,517
  • 8
  • 35
  • 53
2
votes
1 answer

Indirection without using eval

I'm looking for a clean way (without eval command) to do an indirect reference to an array. Here is a more precise description of what I want : function valueof { echo "indirection1 \$$1=${!1}" eval "echo indirection2 \\\$$1=\${$1[@]}" #…
cglacet
  • 8,873
  • 4
  • 45
  • 60
1
vote
1 answer

C# P/Invoke: How to achieve double indirection for a field of a structured parameter

I am calling into a native dll from C#. For the specific function in question, one of the parameters I need is a structure which contains a doubly-indirect field (pointer to a pointer). For example, take the following C prototype and structs: int…
Odrade
  • 7,409
  • 11
  • 42
  • 65
1
vote
2 answers

Delphi - Using different TTable and TQuery as one object

Delphi 2010, Win7 - 64 I am writing an app which involves connecting to different databases. I use two different vendors for database access. I use AnyDAC, by DA-Soft, which allows me to connect to "industrial" databases, Oracle, SQL Server, etc,…
user1009073
  • 3,160
  • 7
  • 40
  • 82
1
vote
0 answers

How can I convert text into a variable name in powershell

I'm trying to convert text selected from a list into a variable name. this is the testing code I'm using $trees = @("oak","pine","teak") $fruit = @("apple","pear","banana") $color = @("red","green","blue") function list($items){ foreach…
ian
  • 11
  • 2
1
vote
1 answer

How to test if R dplyr::select() helper function is NULL inside a function

I know you can use "indirection" when you use dplyr::select() inside a function: myselect1 <- function( df, select_arg ) { df %>% select( {{ select_arg }} ) } starwars %>% myselect1( contains( '_color' ) ) %>% head( n = 3 ) #…
teppo
  • 542
  • 8
  • 11
1
vote
1 answer

How to pass (and set) non-objects by indirection?

NSError objects are frequently used like this (taken from this previous question): - (id)doStuff:(id)withAnotherObjc error:(NSError **)error; I want to achieve something similar with BOOL indirection: - (id)doStuff:(id)withAnotherObjc…
rubergly
  • 878
  • 8
  • 20
1
vote
1 answer

Referencing a variable column value in a Google Sheet formula

I want to use the value of a cell as the column value of a cell reference in a formula. For example: cell A1 has the value 12 In another cell, I want to reference the value of another cell using a hard-coded Row with the value of A1 as the column,…
1
vote
2 answers

PowerShell : how do I indirectly reference a variable

In Powershell, how can I indirectly reference a variable? I have tables which are referenced in many parts of the code, so I have a list of table name like so: $xTableName = "Tbl_x" $yTableName = "Tbl_y" $zTableName = "Tbl_z" I have a function to…
mikec
  • 155
  • 1
  • 17