In Sling, there are two major categories of data types: Built-in data types and custom data types. The built-in types are built into the language as basic building blocks and cannot be extended or added to by the programmer. The custom types, on the other hand, are implemented and extended completely by the application programmer. In method calls, built-in types are passed by either value or reference (depending on the type, see below), whereas object types are always passed by reference.

Primitive Types

Primitive data types are basic building blocks of programs, and are used to store data values of relatively small storage size, such as integers, characters and floating point numbers. In method calls, primitive types are passed by value. The following primitive types are supported in Sling:

  • char (unicode characters)

  • int (signed integers, represented by the native integer format of the underlying platform; bit counts may vary; often 32 bits, but not guaranteed)

  • uint (unsigned version of the integer)

  • short (signed integer data type with the same or smaller storage size as integer; commonly 16 bits, but this is not guaranteed)

  • ushort (unsigned version of the short integer)

  • long (signed integer data type with the same or larger storage size as integer; commonly 64 bits, but this is not guaranteed)

  • ulong (unsigned version of the long integer)

  • int8 (signed integer represented by 8 bits)

  • uint8 (unsigned integer represented by 8 bits)

  • int16 (signed integer represented by 16 bits)

  • uint16 (unsigned integer represented by 16 bits)

  • int32 (signed integer represented by 32 bits)

  • uint32 (unsigned integer represented by 32 bits)

  • int64 (signed integer represented by 64 bits)

  • uint64 (unsigned integer represented by 64 bits)

  • double (double precision floating point numbers)

  • float (single precision floating point numbers)

  • bool (boolean values: true or false)

Built-in Object Types

Built-in object types represent more complex object data types that behave very much like custom data types, but are still built in to the language. All object data types can be used where an object is expected. In method calls, object types are passed by reference.

  • object (generic type that represents all object types and instances of classes)

  • vector (a built-in resizable array type) More information: Sling: Vector operations

  • map (a built-in key/value mapping structure) More information: sling-map

  • string (sequences of characters) More information: sling-string

Note that vector, map and string are all also object types, and can be passed where an object is expected.

Special Built-in Types

Additional "special" built-in types are used for various other purposes. These are NOT object data types, and cannot be used where an "object" data type is expected.

  • array (a zero-based fixed size array indexed with integers; array size is determined upon creation, and cannot be changed without reallocating the array)

  • function (a function pointer that can be called; return value data type and/or data type parameters are supplied as generic parameters)

  • magical (a placeholder for a data type that is not known to Sling, but that is known for an underlying platform or programming language; can be used to directly use native data types of other languages in Sling code)

  • buffer (binary data buffer composed of a sequence of bytes)

  • dynamic (dynamic data type that may hold values of different data types)

  • auto (automatic data type; the compiler determines the actual data type from context)

  • void (refers to no data type at all, or absence of data type or value)

  • tuple (a fixed sequence of values)

  • ptr (memory pointer)

  • unknown (unknown data type; used internally by the compiler, no practical use for this data type exists)

Custom Types

The developer can define new data types entities (see chapter 5). All user-defined entities are also declarations of valid data types, which can also be treated as object instances if necessary.


Twitter Facebook LinkedIn Youtube Slideshare Github