Can .NET do this type of 'Indirection'?

kasdoffe

Well-known member
Joined
Aug 27, 2003
Messages
57
I have about 5 years experience in a language called Cache.

One thing I love regarding this language is something referred to as Indirection. I havent figured out if .NET offers anything like this at all, possibly C# since Cache is based on C.

Heres what Indirection is with Cache.

Suppose I have 1 variable called USER_INPUT that is set to what a user inputs into a field and I have a variable FIELD_NAME that is the name of the current field that a user is inputting. I have 2 fields on a form. These fields are named FIRST_NAME and LAST_NAME. So, if the user enters John in the FIRST_NAME field, the USER_INPUT variable would equal John and FIELD_NAME would equal "FIRST_NAME".
Makes sense so far right?

Well, the nice thing about indirection is I can say in Cache: S @FIELD_NAME=USER_INPUT
In english this says, set the variable named in FIELD_NAME to the value of USER_INPUT, which means FIRST_NAME now equals "John".

Now the even cooler part about indirection is the ability to call a function named in a variable.

Suppose I have a Main function that accepts 2 parameters COMMAND and BUFFER. Besides the main function I have these many other functions that accept 1 parameter also called BUFFER. Well, with indirection i can say: D @COMMAND(BUFFER). Suppose COMMAND="IncrementCount" and BUFFER="1". Executing this command will call the IncrementCount function and pass BUFFER as a parameter, incrementing the counter by 1.

Cool eh? The usefulness of this is endless in Cache. I have already found similar instances where I wish I could use this in .NET, specifically C#.

Is this even possible?
 
Back
Top