Fields

Fields are data variables that are stored within a type or an object instance.

Fields are defined within a type with their value type and possibly a static property. All field names must begin with a @ sign!

type dude
{
  static int @count
  float @power
  string @name
} 

When accessing the field locally (from the type itself), you should also state the @ prefix:

type dude
{
  static int @count = 0
  float @power
  string @name

  void construct: float power, string name
  {
    @power = power
    @name = name
    @count += 1
  }
} 

When you're accessing the field of an object or a static field from outside the type, the @ prefix is not used:

var kamina = new dude 9000.1, "Kamina"
print kamina.name // "Kamina"
print dude:count // 1 

Last edited Mar 15, 2011 at 10:12 AM by impworks, version 4

Comments

No comments yet.