RAD Studio (Common)
ContentsIndex
PreviousUpNext
Changes in Standard Functions and Grammar

Here is a list of standard function changes to support generics. 

Example forms:

         Instantiated type      : TFoo<Integer,String>
        Open constructed type  : TFoo<Integer,T>
        Generic type        : TFoo<,>
        Type parameter:        T

Standard functions:

        procedure Initialize(var X; Count:Cardinal);                        [Win32]
        procedure Finalize(var X);                                          [Win32]
                Instantiated type      : allowed
                Open constructed type  : allowed 
                Generic type     : NOT allowed
                Type parameter       :allowed
        
        function High(X:TypeId): Integer|Int64|UInt64;
        function Low(X:TypeId): Integer|Int64|UInt64;
                Instantiated type      : allowed
                Open constructed type  : NOT allowed 
                Generic type     : NOT allowed
                Type parameter       : NOT allowed
        
        function Default(X:TYPE_ID): valueOfTypeId>;
                Instantiated type      : allowed
                Open constructed type  : allowed 
                Generic type     : NOT allowed
                Type parameter       : allowed
        
        function New;
   
        // New( PtrVar );                                                   [Win32]
        // New( PtrToRecordOrObjectVar,<CtorIdent>  );                      [Win32]
        // New( PtrToRecordOrObjectVar, <CtorIdent> ( CtorParams ) );       [Win32]
        // P := New( PtrType );                                             [Win32]
        // P := New( PtrTypeOfRecordOrObject, <CtorIdent> );                [Win32]
        // P := New( PtrTypeOfRecordOrObject, <CtorIdent> ( CtorParams ) ); [Win32]
                Instantiated type      : allowed
                Open constructed type  : NOT allowed 
                Generic type     : NOT allowed
                Type parameter       : NOT allowed
        
        function SizeOf(TYPE_ID): PosInt;
                Instantiated type      : allowed
                Open constructed type  : allowed 
                Generic type     : NOT allowed
                Type parameter       : allowed
        
        function TypeInfo;
        function TypeHandle;
        function TypeId;

        // function TypeHandle(Identifier): Pointer;                  [Win32]
 
        // function TypeInfo(Identifier): Pointer;                    [Win32]
   
        // function TypeOf(object): Pointer;                          [Win32]
               Instantiated type      : allowed
                Open constructed type  : allowed 
                Generic type     : NOT allowed
                Type parameter       : allowed

These changes are in support of generics or Generic types.

 { Type Declarations }
            
            TypeDeclaration -> [ CAttrs ] Ident '=' Type
                                    -> [ CAttrs ] Ident '=' RecordTypeDecl
                                    -> [ CAttrs ] Ident '=' ClassTypeDecl
                                    -> [ CAttrs ] Ident '=' InterfaceTypeDecl
                                    -> [ CAttrs ] Ident '=' ClassHelperTypeDecl
                                    -> [ CAttrs ] Ident '=' RecordHelperTypeDecl
                                    -> [ CAttrs ] Ident '=' ObjectTypeDecl             {Win32 only}
                                    -> [ CAttrs ] Ident '=' DispatchInterfaceType      {Win32 only}
                                    -> [ CAttrs ] Ident '=' TYPE TypeId

            {NEW}           -> [ CAttrs ] Ident TypeParams '=' RecordTypeDecl
            {NEW}           -> [ CAttrs ] Ident TypeParams '=' ClassTypeDecl
            {NEW}           -> [ CAttrs ] Ident TypeParams '=' InterfaceTypeDecl
            {NEW}           -> [ CAttrs ] Ident TypeParams '=' Type
            
            {NEW} TypeParams -> '<' TypeParamDeclList '>'
            
            {NEW} TypeParamDeclList -> TypeParamDecl/';'...
            
            {NEW} TypeParamDecl -> TypeParamList [ ':' ConstraintList ]
            
            {NEW} TypeParamList -> ( [ CAttrs ] [ '+' | '-' [ CAttrs ] ] Ident )/','...
            
            {NEW} ConstraintList -> Constraint/','...
            
            {NEW} Constraint -> CONSTRUCTOR
            {NEW}            -> RECORD
            {NEW}            -> CLASS
            {NEW}            -> TypeId
            
            MethodResolutionClause -> FUNCTION InterfaceIdent '.'
            {OLD}                     Ident               '=' Ident              ';'
            {NEW}                     Ident [ TypeArgs ]  '=' Ident [ TypeArgs ] ';'
                                                            -> PROCEDURE InterfaceIdent '.'
            {OLD}                     Ident               '=' Ident              ';'
            {NEW}                     Ident [ TypeArgs ]  '=' Ident [ TypeArgs ] ';'
            
            FunctionHeading -> [ CLASS ] FUNCTION Ident
            {NEW}              [ FormalTypeParamList ]
                                      [ FormalParameterList ] ':' TypeIdStringFile
            
            ProcedureHeading -> [ CALSS ] PROCEDURE Ident
            {NEW}               [ FormalTypeParamList ]
                                       [ FormalParameterList ]
            
            ClassOperatorHeading -> CLASS OPERATOR OperatorIdent
            {NEW}                   [ FormalTypeParamList ]
                                           FormalParameterList : TypeIdStringFile
            
            ConstructorHeading -> CONSTRUCTOR Ident
            {NEW}                 [ FormalTypeParamList ]
                                         [ FormalParameterList ]
            
            RecordConstructorHeading -> CONSTRUCTOR Ident
            {NEW}                       [ FormalTypeParamList ]
                                               FormalParameterList
            
            DestructorHeading -> DESTRUCTOR Ident
            {NEW}                [ FormalTypeParamList ]
                                        [ FormalParameterList ]
            
            MethodBodyHeading -> [ CLASS ] FUNCTION NSTypeId '.' Ident
            {NEW}                [ FormalTypeParamList ]
                                        [ FormalParameterList ] ':' TypeIdStringFile
                                   -> [ CLASS ] PROCEDURE NSTypeId '.' Ident
            {NEW}                [ FormalTypeParamList ]
                                        [ FormalParameterList ]
            
            ProcedureTypeHeading -> PROCEDURE
            {NEW}                   [ FormalTypeParamList ]
                                           [ FormalParameterList ]
            
            FunctionTypeHeading -> FUNCTION
            {NEW}                  [ FormalTypeParamList ]
            [ FormalParameterList ] ':' TypeIdStringFile
            
            FormalTypeParamList -> '<' TypeParamDeclList >'
            
            
            { Types }
            
            Type -> TypeId
                     -> SimpleType
                     -> StructualType
                     -> PointerType
                     -> StringType
                     -> ProcedureType
                     -> VariantType                                                {Win32 only}
                     -> ClassRefType
                     -> TypeRefType
            {NEW}-> ClassTypeId TypeArgs
            {NEW}-> RecordTypeId TypeArgs
            {NEW}-> InterfaceIdent TypeArgs
            
            {NEW} TypeArgs -> '<' ( TypeId | STRING )/','... '>'
            
            
            { Attributes }
            
            CAttrExpr -> ConstExpr
                              -> TYPEOF '(' TypeId ')'
            {NEW}     -> TYPEOF '(' TypeId '<' [ ','... ] '>' ')'
            {NEW}     -> TYPEOF '(' TypeId '<' TypeId/','... '>' ')'
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!