
01-28-2009, 10:48 PM
|
|
Incubator
|
 |
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
|
|
|
I expect that a hash table is used for storing the variables of an object, so a TStaticVar is a good choice in that situation.
As I was typing that I just had an idea about associative arrays. I think that in the case of an object, 'a["b"]' would map to 'a.b'. This would allow people to use a more appropriate syntax so it is obvious the coder is using the object as an associative array. In the case where b is a number, it would map to 'a.index<b>' (without brackets).
Example:
staff = new TStaticVar();
staff.timeout = 5;
staff["timeout"] = 5; // same as the previous
staff.(@ "lol" @ 3) = "pancake";
staff["lol" @ 3] = "pancake"; // same as the previous, but clearer (imho)
staff[5] = "five";
echo("5: " @ staff.index5); // example of how number is mapped to variable name |
|
|
|