Oxygen Basic
Programming => Example Code => General => Topic started by: Charles Pegge on May 16, 2011, 09:43:29 AM
-
Often a type is only used in one place and is not required in a header file.
Anonymous types removes the unnecessary clutter of formally defining a type. It is best used for simple structures like pixels, vectors or quads.
Example:
'===================================
'Instant Anonymous User Defined Type
'===================================
'
' specify type, create variable and assign values:
'
dim as (byte r,g,b) pix(16) <= (2,4,6,20,40,60)
print pix(2).g ' result 40
This feature is now available in then Oxygen (in progress) release.
Charles
-
It is also possible to give the type a name, using the same syntax.
Then you can inherit the type.
Example:
'===================================
'Short Inline User Defined Type
'===================================
'
' specify type, create variable and assign values:
'
dim as pixel4f (single r,g,b,a) pixel
dim as materialf (pixel4f ambient,diffuse, specular, single shininess) material[16]
print structureof materialf
Charles
-
Amazing stuff Charles. Oxygen was already a cool language, and it is just getting cooler!
-
Oxygen is slightly smaller in size than it was 6 months ago. I have been able to gradually condense the code while extending the features - and a few items have also become redundant meanwhile.
Charles