Changes between Version 18 and Version 19 of TypesOverview
- Timestamp:
- 06/04/13 08:52:03 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TypesOverview
v18 v19 7 7 * character literals are single quoted and preceeded by a c. 8 8 * For example {{{ var underscore as char = c'_' }}} 9 * int (= int32)10 * uint (= uint32)11 * float (= float64)9 * int (= '''int32''') 10 * uint (= '''uint32''') 11 * float (= '''float64''') 12 12 * decimal 13 * number (defaults to decimal, Can change with compiler -number: option)13 * number (defaults to '''decimal''', Can change with compiler -number: option) 14 14 * dynamic (see DynamicType) 15 15 * Can be explicit wrt !Sizes/Sign … … 39 39 * IEnumerable, IEnumerable<of T> (but use T* instead; see streams below) 40 40 * IComparable, IComparable<of T> 41 * Mixins 42 * Reusable code implementation ( of interface or abstract class or just some capability) 43 * Not instantiated directly 44 * class declares use of a mixin explicitly and the implementation is melded into the class implicitly. 41 45 42 46 * Nilable Type 43 * Specifies that a variable can be either that type or nil(no-valued, Null)47 * Specifies that a variable can be either that type or '''nil''' (no-valued, Null) 44 48 * 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"49 * requires explicit casting to lose or gain nilability ( {{{ to !, to ? }}} ) 50 * Foo? - indicates nilable type Foo - can be type "'''Foo'''" or "'''nil'''" 47 51 * applicable to all types 48 * " dynamic" implies "dynamic?" meaning you can always pass "nil" where "dynamic" is expected52 * "'''dynamic'''" implies "'''dynamic?'''" meaning you can always pass "'''nil'''" where "'''dynamic'''" is expected 49 53 50 54 * Streams … … 55 59 * You can get the type of "x" with "x.getType" (library call) or "x.typeOf" (cobra language extension) 56 60 * You can make instances with a type at run-time 57 * t = x.typeOf 58 * obj1 = t() 59 * obj2 = t(0, 0) 61 62 {{{ 63 #!cobra 64 t = x.typeOf 65 obj1 = t() 66 obj2 = t(0, 0) 67 }}} 68 60 69 61 70 * Generics … … 63 72 * These are identical to .NET generics as found in C# and VB. 64 73 * Examples: List<of int>, List<of String>, Dictionary<of String, int> 65 * The general form is: Name<of T, U...> for a template where T a re 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>74 * The general form is: Name<of T, U...> for a template where T and U are type placeholders. 75 * example: {{{ class ATag<of T> }}} 76 * A generic type is instantiated by using the same name with a concrete type replacing the type placeholders[[BR]] 77 e.g {{{ ATag<of String>() }}} 69 78 * You can declare your own and or instantiate generic template types defined locally or in platform libraries. 70 79 * You can overload by number of type arguments. In other words, Foo<of T> and Foo<of T, U> are two different types.