C/C++ doesn't really have anything of this nature in its language. For example, an eScript struct:
Code: Select all
var myStruct := struct;
myStruct.+field1 := 1.0;
myStruct.+field2 := 2;
-or-
var myStruct := struct{"field1"->1.0, "field2"->2};
This results in a variable called "myStruct" of type struct with two fields, a float and an int.
A C-Struct of the same format would be declared like this:
Code: Select all
struct MyStruct
{
float field1;
int field2;
};
MyStruct myStruct;
myStruct.field1 = 1.0f;
myStruct.field2 = 2;
The end result is the similar, but different. Here, we have a variable called "myStruct" of type MyStruct (a difference here) with
only ever two fields, a float and an int.
C/C++ are
typed languages. Unlike eScript, structs are not defined as variables. Structs are data types, like
int or
float, except that they're defined by the programmer. Because structs are types, they cannot be returned by functions, or used to initialize a variable. It would be like writing "return int;" It just makes no sense.
However, eScript uses structs as data, thus they can be assigned to variables (see above). Since they can, it makes sense that they can be used as variables, such as in returning from functions, or assigning directly into a dictionary field. You would not, for instance, do this:
Code: Select all
var five := 5;
myDictionary["entry"] := five;
-or-
var five := 5;
return five;
when this would do:
Code: Select all
[code]myDictionary["entry"] := 5;
-or-
return 5;
As it stands now, it is allowable (ie: it compiles without error or warning) but gives incorrect results. One way or the other, it should be fixed.