Scripting - Value Types - how to approach this?
<p>I am writing my own scripting language and need to handle value types somehow.</p>

<p>I need to define a variable values in my script like in the snippet below</p>

<pre><code>#Var #Name="Alpha" #Class="Float" #Value=1.0
#Var #Name="Beta" #Class="Int" #Value=1
#Var #Name="Delta" #Class="Vector2" #Value=(1.0,2.0)
#Var #Name="Echo" #Class="String" #Value="abcdefgh"
</code></pre>

<p>As you can see, each #Var has a #Class defining what <strong>type</strong> of value to expect.</p>

<p>The problem is i don't know how to approach it 'easily' so that i can manage the values later on in a simple manner:</p>

<pre><code>float fAlpha = GetVar("Alpha")-&gt;GetValue();
fAlpha = 150.0f;
GetVar("Alpha")-&gt;SetValue(fAlpha);
</code></pre>

<p>...</p>

<pre><code>CVector2 vDelta = GetVar("Delta")-&gt;GetValue();
vDelta=CVector2(10.0,20.0);
GetVar("Delta")-&gt;SetValue(vDelta)
</code></pre>

<p>I can check for #Var #Class all over the time, but i am looking for something more clear/OO.</p>

<pre><code>if(GetVar("Alpha")-&gt;GetClass() == "Float")
{
float fAlpha = GetVar("Alpha")-&gt;GetValue();
}
</code></pre>

<p>Can somebody shed a bit of light on how do you approach this ?</p>

<p>Thanks.</p>
