Exit Full View

Feather2 / documentation / TypeSystem.md

Type System

Automatic Type Conversions

Feather performs automatic conversion between number types. It also boxes/unboxes primitive types automatically.

Feather uses these keywords for the primitive types : bool, byte, char, short, int, long, float and double.

char types are sometimes automatically cast to int. e.g.

"Hello".indexOf( 'H' )

Note that String.indexOf() takes an int parameter (a unicode codePoint), not a char.

However, when used as part of an expression, char is NOT treated as a number. e.g.

'A' * 2 // Illegal

Boxed Types

The default configuration does NOT automatically import the boxed types (Double Integer etc.) This prevents accidental use of Double instead of double etc.

If feather is embedded within your application as a scripting language, you can change this by adding Double, Integer etc. to the implied imports :

// Kotlin Code
for ( boxed in arrayOf( "Boolean", "Byte", "Character", "Integer", "Long", "Float", "Double") ) {
    myFeatherConfiguration.impliedImportClasses[boxed] = "java.lang.$boxed"
}

Or, a script can import the boxed types manually. e.g. :

import java.lang.Double

Back to Contents