I am trying to find the right language to describe the following concept. Maybe someone can help me out.
This is a general question about programming but I'll use Python and R for examples.
In Python, we can put something in a dictionary like this
myData = {}
myData["myField"] = 14
In R, for example, using the data.table
package, we could write something like
data = data.table(x = c(1, 2, 3))
data[,myField: = x^2]
These do different things but compare the second line of each of them. In Python, the "myField"
is a string. In the R data.table
example, there is no string. The R example is kinda nice because it saves you typing but then it gives you trouble if want to write a program where myField
is a variable. In Python that is trivial because you can just do
myData[myVariable] = 14
with myVariable
being defined as another string. In R, you can do this too but have to use a different syntax which means you have to know two completely different syntactical ways of programming it.
My question: What is this called? I know it has something to do with scoping rules, (perhaps meta programming?), but can't figure out the right language for it. Anyone?