Cind programming language

Language definition Examples Download Contact

Object's properties

A property is a value assigned to the object, which can be accessed by a name.
Properties can be assigned to any object.

The syntax to set property to the given object x, is the object, next a colon character( : ) and then a property name. Examples:

x:city = 'Paris'; x:price = 12.5; x:position = (0,1);

The syntax to read property from the object, similarly, is:

y = x:position;

It is allowed to access properties by giving the name in the string value, by putting it inside brackets [ ... ].
For example:

x:["position"] = ...

which is equivalent to x:position.

Property of any name may be assigned to the given object, including the language keywords.
It is not possible to specify the data type of any property.

Properties in class

Properties of an object can be also set directly in its class definition.

class c { name: "triangle"; angle: 90; plot: fun() { .... }; .... }

Properties declared in class definition are assigned to object during object's creation, and after that, they can be freely changed or removed.

For more about classes see Classes.

Set of properties

Properties can be managed by special syntax x:[]
which is an object that represents a set of properties assigned to the given object x.

There are three methods accepted by the object of the set of properties:

  • add(name,value) - adds property name with given value,
  • remove(name) - removes property of given name,
  • getNames() - returns an array of names of all assigned properties.


x:[].add("color","red"); // equal to: x:color = "red"; x:[].remove("brush"); x:[].getNames().iterate(fun(name) { host.println("has prop: "+name); });

Properties of system objects and external objects

Properties can be assigned to any object, even to system objects (ie: 1:abc = 2), but depending on the execution environment, properties assigned to the system objects may be lost or changed, because execution software may interpret system objects in own way, move them over different environments, and, for example, may convert to other objects, that are coming from other environments.

In case of external objects (objects that exists in different execution environment), it is not allowed to access their properties, and any access will throw an exception.

Cind programming language 1.0.4