Revision history for KeyPgOpIs


Revision [22023]

Last edited on 2017-11-21 01:27:23 by JeffMarshall [updated]
Additions:
{{fbdoc item="back" value="CatPgOpConditional|Relational Operators"}}{{fbdoc item="back" value="CatPgOperators|Operators"}}{{fbdoc item="back" value="CatPgOpTypeclass|Type or Class Operators"}}
Deletions:
{{fbdoc item="back" value="CatPgOpConditional|Relational Operators"}}{{fbdoc item="back" value="CatPgOperators|Operators"}}


Revision [21798]

Edited on 2017-07-29 02:48:54 by fxm [Cited the acronym RTTI]
Additions:
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on Run-Time Type Information (RTTI), it can only be used with types that are derived from the built-in ##[[KeyPgObject|Object]]## type using ##[[KeyPgExtends|Extends]]##. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
Deletions:
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject|Object]]## type using ##[[KeyPgExtends|Extends]]##. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.


Revision [21038]

Edited on 2016-03-13 06:53:22 by fxm [Formatting]

No Differences

Revision [20388]

Edited on 2016-02-10 16:04:47 by DkLwikki [Update link format]
Additions:
The expression to check, an object of a type that is directly or indirectly derived from ##[[KeyPgObject|Object]]## using ##[[KeyPgExtends|Extends]]##.
The ##**Is**## operator must be used in conjunction with inheritance in order to check compatibility between objects and types from an inheritance structure extending the built-in ##[[KeyPgObject|Object]]## type.
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject|Object]]## type using ##[[KeyPgExtends|Extends]]##. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
Extending the built-in ##[[KeyPgObject|Object]]## type allows to add an extra hidden vtable pointer field at the top of the ##[[KeyPgType|Type]]##. The vtable is used to access information for run-time type identification used by the ##**Is**## operator.
- ##[[KeyPgExtends|Extends]]##
- ##[[KeyPgObject|Object]]##
- ##[[KeyPgIs|Is (Select Case)]]##
- ##[[KeyPgTypeof|Typeof]]##
Deletions:
The expression to check, an object of a type that is directly or indirectly derived from ##[[KeyPgObject Object]]## using ##[[KeyPgExtends Extends]]##.
The ##**Is**## operator must be used in conjunction with inheritance in order to check compatibility between objects and types from an inheritance structure extending the built-in ##[[KeyPgObject Object]]## type.
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
Extending the built-in ##[[KeyPgObject Object]]## type allows to add an extra hidden vtable pointer field at the top of the ##[[KeyPgType Type]]##. The vtable is used to access information for run-time type identification used by the ##**Is**## operator.
- ##[[KeyPgExtends Extends]]##
- ##[[KeyPgObject Object]]##
- ##[[KeyPgIs Is (Select Case)]]##
- ##[[KeyPgTypeof Typeof]]##


Revision [17960]

Edited on 2016-01-14 14:42:34 by FxMwikki [Refining the first sentence]
Additions:
Check if an object is compatible to a type derived from its compile-time type
(in the context of inheritance)
Deletions:
Check from its type at compile-time, whether an object is compatible to a type derived, in an inheritance context


Revision [17905]

Edited on 2016-01-13 12:48:31 by FxMwikki [Added reference to 'Extends']
Additions:
The expression to check, an object of a type that is directly or indirectly derived from ##[[KeyPgObject Object]]## using ##[[KeyPgExtends Extends]]##.
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
Deletions:
The expression to check, an object of a type that is directly or indirectly derived from ##[[KeyPgObject Object]]##.
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.


Revision [17901]

Edited on 2016-01-12 06:14:00 by FxMwikki [Added: This operator cannot be overloaded]
Additions:
This operator cannot be overloaded.


Revision [17900]

Edited on 2016-01-11 09:23:21 by FxMwikki [Improved first sentence]
Additions:
Check from its type at compile-time, whether an object is compatible to a type derived, in an inheritance context
Deletions:
Check, from its type at compile-time, whether an object is compatible to a type derived


Revision [17899]

Edited on 2016-01-10 03:46:56 by FxMwikki [Added link to Typeof]
Additions:
- ##[[KeyPgTypeof Typeof]]##


Revision [17898]

Edited on 2016-01-09 09:56:51 by FxMwikki [First line: rewording - Description: adding a first sentence defining the allowed use case]
Additions:
Check, from its type at compile-time, whether an object is compatible to a type derived
Deletions:
Checks whether an object is compatible to a type derived from its compile-time type


Revision [17897]

Edited on 2016-01-09 08:59:20 by FxMwikki [Added in the description paragraph: a first sentence defining the allowed use case]
Additions:
The ##**Is**## operator must be used in conjunction with inheritance in order to check compatibility between objects and types from an inheritance structure extending the built-in ##[[KeyPgObject Object]]## type.


Revision [17014]

Edited on 2014-03-13 08:02:07 by FxMwikki [Corrected the mix-up of terms between 'compile-time' and 'run-time']
Additions:
Checks whether an object is compatible to a type derived from its compile-time type
The child type to check for. This type must be directly or indirectly derived from the type of //expression// (the compile-time type of the object).
The ##**Is**## operator is successful not only for the real-type (the "lowest"), but also for its base-types, as long as they are still below the type of //expression// (the compile-time type). In order to determine the real-type, all possibilities from lowest to highest must be checked.
Deletions:
Checks whether an object is compatible to a type derived from its runtime-type
The child type to check for. This type must be directly or indirectly derived from the type of //expression// (the runtime-type of the object).
The ##**Is**## operator is successful not only for the real-type (the "lowest"), but also for its base-types, as long as they are still below the type of //expression// (the runtime-type). In order to determine the real-type, all possibilities from lowest to highest must be checked.


Revision [16462]

Edited on 2012-11-22 07:25:04 by FxMwikki [Added short introduction to vtable]
Additions:
Extending the built-in ##[[KeyPgObject Object]]## type allows to add an extra hidden vtable pointer field at the top of the ##[[KeyPgType Type]]##. The vtable is used to access information for run-time type identification used by the ##**Is**## operator.


Revision [16240]

Edited on 2012-08-08 11:17:59 by FxMwikki [Clarification and complement]
Additions:
Checks whether an object is compatible to a type derived from its runtime-type
The child type to check for. This type must be directly or indirectly derived from the type of //expression// (the runtime-type of the object).
Returns negative one (##-1##) if the expression is an object of real-type ##//typename//## or one of its base-types derived from the //expression// type, or zero (##0##) if it's an object of an incompatible type.

The ##**Is**## operator is successful not only for the real-type (the "lowest"), but also for its base-types, as long as they are still below the type of //expression// (the runtime-type). In order to determine the real-type, all possibilities from lowest to highest must be checked.
Deletions:
Checks whether an object is compatible to a type derived from its type
The child type to check for. This type must be directly or indirectly derived from the type of //expression//.
Returns negative one (##-1##) if the expression is an object of type ##//typename//## or one of its derived types, or zero (##0##) if it's an object of an incompatible type.


Revision [15831]

Edited on 2012-01-25 06:14:13 by DkLwikki [Clarified & better example]
Additions:
Checks whether an object is compatible to a type derived from its type
Deletions:
Checks whether an object is of a certain type


Revision [15830]

Edited on 2012-01-25 06:13:18 by DkLwikki [Clarified & better example]
Additions:
The expression to check, an object of a type that is directly or indirectly derived from ##[[KeyPgObject Object]]##.
The child type to check for. This type must be directly or indirectly derived from the type of //expression//.
Returns negative one (##-1##) if the expression is an object of type ##//typename//## or one of its derived types, or zero (##0##) if it's an object of an incompatible type.
The ##**Is**## operator is a binary operator that checks whether an object is compatible to its derived types at run-time. Because ##**Is**## relies on run-time type information, it can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
type Vehicle extends object
as string name
type Car extends Vehicle
type Cabriolet extends Car
type Bike extends Vehicle
print "Identifying:"
'' Not a Vehicle object?
if not (*p is Vehicle) then
print , "unknown object"
return
'' The cast is safe, because we know it's a Vehicle object
print , "name: " & cptr(Vehicle ptr, p)->name
if *p is Car then
print , "It's a car"
if *p is Cabriolet then
print , "It's a cabriolet"
if *p is Bike then
print , "It's a bike"
dim as Car ford
ford.name = "Ford"
identify(@ford)
dim as Cabriolet porsche
porsche.name = "Porsche"
identify(@porsche)
dim as Bike mountainbike
mountainbike.name = "Mountain Bike"
identify(@mountainbike)
dim as Vehicle v
v.name = "some unknown vehicle"
identify(@v)
dim as Object o
identify(@o)
Deletions:
The expression to check. It must be an object of a type with run-time type information.
The type to check against. This type must be derived from the //expression//'s type.
Returns negative one (##-1##) if the expression is an object of type ##//typename//## or one of its derived types, or zero (##0##) if it's an object of another type.
The ##**Is**## operator is a binary operator that checks whether a certain expression is an object of a specific type. ##**Is**## relies on run-time type information, and its purpose is to check an object against types derived from the object's type.

##**Is**## can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. ##[[KeyPgObject Object]]## is responsible for adding the run-time type information needed for ##**Is**## to work. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
type A extends object
as integer a
type B extends object
as string b
if *p is A then
'' If it's an A, then the cast is safe
print "A", cptr(A ptr, p)->a
elseif *p is B then
print "B", cptr(B ptr, p)->b
else
print "unknown"
dim as A aa
dim as B bb
dim as object cc
aa.a = 1
bb.b = "hello"
identify(@aa)
identify(@bb)
identify(@cc)


Revision [15825]

Edited on 2012-01-24 15:37:34 by CountingPine [Clarification (IMO) on return value; formatting + typo]
Additions:
Returns negative one (##-1##) if the expression is an object of type ##//typename//## or one of its derived types, or zero (##0##) if it's an object of another type.
The ##**Is**## operator is a binary operator that checks whether a certain expression is an object of a specific type. ##**Is**## relies on run-time type information, and its purpose is to check an object against types derived from the object's type.
##**Is**## can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. ##[[KeyPgObject Object]]## is responsible for adding the run-time type information needed for ##**Is**## to work. The compiler disallows using ##**Is**## for checks that can be solved at compile-time.
Deletions:
Returns negative one (-1) if the expression is an object of type //typename//, or zero (0) if it's an object of another type.
The **Is** operator is a binary operator that checks whether a certain expression is an object of a specific type. **Is** relies on run-time type information, and its purpose is to check an object against types derived from the object's type.
**Is** can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. ##[[KeyPgObject Object]]## is reponsible for adding the run-time type information needed for **Is** to work. The compiler disallows using **Is** for checks that can be solved at compile-time.


Revision [15806]

Edited on 2012-01-23 21:45:34 by DkLwikki [Add IS operator page]
Additions:
**Is** can only be used with types that are derived from the built-in ##[[KeyPgObject Object]]## type using ##[[KeyPgExtends Extends]]##. ##[[KeyPgObject Object]]## is reponsible for adding the run-time type information needed for **Is** to work. The compiler disallows using **Is** for checks that can be solved at compile-time.
Deletions:
**Is** can only be used with types that are derived from the built-in [[KeyPgObject Object]] type using [[KeyPgExtends Extends]]. [[KeyPgObject Object]] is reponsible for adding the run-time type information needed for **Is** to work. The compiler disallows using **Is** for checks that can be solved at compile-time.


Revision [15792]

Edited on 2012-01-23 19:46:06 by DkLwikki [Add IS operator page]
Additions:
- ##[[KeyPgIs Is (Select Case)]]##
Deletions:
- ##[[KeyPgIs Is]]##


Revision [15791]

The oldest known version of this page was created on 2012-01-23 19:45:16 by DkLwikki [Add IS operator page]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode