Author Topic: Anonymous Types  (Read 2708 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Anonymous Types
« 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:

Code: [Select]

  '===================================
  '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

Charles Pegge

  • Guest
Re: Anonymous Types
« Reply #1 on: May 16, 2011, 08:41:46 PM »

It is also possible to give the type a name, using the same syntax.

Then you can inherit the type.

Example:

Code: [Select]

  '===================================
  '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

kryton9

  • Guest
Re: Anonymous Types
« Reply #2 on: May 16, 2011, 10:45:06 PM »
Amazing stuff Charles. Oxygen was already a cool language, and it is just getting cooler!

Charles Pegge

  • Guest
Re: Anonymous Types
« Reply #3 on: May 16, 2011, 11:41:13 PM »

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