Changes between Version 17 and Version 18 of TypesOverview
- Timestamp:
- 04/11/12 05:30:19 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TypesOverview
v17 v18 5 5 * bool 6 6 * char 7 * character literals are preceeded by a c. For example var underscore as char = c'_' 8 * int (= int32) 7 * character literals are single quoted and preceeded by a c. 8 * For example {{{ var underscore as char = c'_' }}} 9 * int (= int32) 9 10 * uint (= uint32) 10 * float 11 * float (= float64) 11 12 * decimal 12 * number ( = decimal, change with-number: option)13 * number (defaults to decimal, Can change with compiler -number: option) 13 14 * dynamic (see DynamicType) 14 * Explicit !Sizes/Sign15 * Can be explicit wrt !Sizes/Sign 15 16 * int8, int16, int32, int64 16 17 * uint8, uint16, uint32, uint64 17 18 * float32, float64 18 19 * PrimitiveTypeMembers 20 19 21 * Complex Types 20 22 * Class … … 29 31 * No inheritance (other than Object) 30 32 * Value-based 31 * Popular structs 33 * Popular structs (CLR) 32 34 * !DateTime, Color (System.Drawing) 33 35 * Interface … … 37 39 * IEnumerable, IEnumerable<of T> (but use T* instead; see streams below) 38 40 * IComparable, IComparable<of T> 41 39 42 * Nilable Type 40 * foo? - can be "foo" or "nil" 41 * applies to all types 43 * Specifies that a variable can be either that type or nil (no-valued, Null) 44 * A nilable type is not directly assignable to a non nilable variable of the same Type 45 * requires explicit casting to lose or gain nilability ( {{{ to !, to ? }}} 46 * Foo? - indicates nilable type Foo - can be type "Foo" or "nil" 47 * applicable to all types 42 48 * "dynamic" implies "dynamic?" meaning you can always pass "nil" where "dynamic" is expected 49 43 50 * Streams 44 51 * foo* - walkable collection of zero or more objects of type foo 45 52 * See StreamType 53 46 54 * Working with types at run-time 47 55 * You can get the type of "x" with "x.getType" (library call) or "x.typeOf" (cobra language extension) … … 50 58 * obj1 = t() 51 59 * obj2 = t(0, 0) 60 52 61 * Generics 53 * Classes, interfaces and structs can all be generic --parameterized by type.62 * Classes, interfaces and structs can all be generic -- parameterized by type. 54 63 * These are identical to .NET generics as found in C# and VB. 55 64 * Examples: List<of int>, List<of String>, Dictionary<of String, int> 56 * The general form is: Name<of T, U, ...> 57 * You can declare your own 65 * The general form is: Name<of T, U...> for a template where T are type placeholders. 66 * example: class ATag<of T> 67 * A generic type is instantiated by using the same name with a concrete type replacing the type placeholders 68 e.g ATag<of String> 69 * You can declare your own and or instantiate generic template types defined locally or in platform libraries. 58 70 * You can overload by number of type arguments. In other words, Foo<of T> and Foo<of T, U> are two different types. 59 71 * Methods can be generic: def foo<of T>(a as T, b as T) 72 60 73 * See also 61 74 * [http://cobra-language.com/forums/viewtopic.php?f=4&t=291 Discussion on types]