Revision history for KeyPgOpPtrIndex


Revision [22764]

Last edited on 2019-07-04 00:23:25 by fxm [merged the page POINTER (KeyPgPointer) within page PTR (KeyPgPtr)]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPtr|pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T//
Like pointer arithmetic, any type of ##[[KeyPgPtr|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPtr|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
Deletions:
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T//
Like pointer arithmetic, any type of ##[[KeyPgPointer|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.


Revision [22745]

Edited on 2019-07-02 10:40:34 by fxm [Added a caution about a null pointer use or a resulting address corresponding to invalid memory access]
Additions:
This operator must not be used in case of null pointer because reference is undefined (inducing runtime error).
Otherwise, the user must ensure that the offset value (##//rhs//##) is in a range that allows an access to valid memory. Outside this range, results are undefined.


Revision [21771]

Edited on 2017-06-29 03:23:20 by fxm [Added a small explanation]
Additions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##" because the reference can be thought of as a pointer having as value the memory location "##(//lhs// [[KeyPgOpAdd|+]] //rhs//)##", and which is implicitly dereferenced; both do exactly the same thing.
Deletions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##" because a reference can be thought of as a pointer that is implicitly dereferenced; both do exactly the same thing.


Revision [21770]

Edited on 2017-06-27 15:43:48 by fxm [Added a very small explanation]
Additions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##" because a reference can be thought of as a pointer that is implicitly dereferenced; both do exactly the same thing.
Like pointer arithmetic, any type of ##[[KeyPgPointer|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
Deletions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##"; both do exactly the same thing. Like pointer arithmetic, any type of ##[[KeyPgPointer|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.


Revision [21345]

Edited on 2016-04-15 03:26:36 by fxm [Added reference to KeyPgOperator for appropriate syntax when overloaded as member operator]
Additions:
This operator can be overloaded for user-defined types as a member ##[[KeyPgOperator|Operator]]## using the appropriate syntax.
Deletions:
This operator can be overloaded for user-defined types.


Revision [21058]

Edited on 2016-03-13 08:35:04 by fxm [Formatting]
Additions:



Revision [20409]

Edited on 2016-02-10 16:05:30 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **[]** ( [[KeyPgByref|byref]] //lhs// [[KeyPgAs|as]] //T// [[KeyPgPointer|pointer]], [[KeyPgByref|byref]] //rhs// [[KeyPgAs|as]] [[KeyPgInteger|integer]] ) [[KeyPgByrefFunction|byref]] [[KeyPgAs|as]] //T//
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf|*]](//lhs// [[KeyPgOpAdd|+]] //rhs//)##"; both do exactly the same thing. Like pointer arithmetic, any type of ##[[KeyPgPointer|Pointer]]## can be indexed except for an ##[[KeyPgAny|Any]]## ##[[KeyPgPointer|Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
- [[ProPgPtrArithmetic|Pointer Arithmetic]]
- ##[[KeyPgOpValueOf|Operator * (Value of)]]##
- ##[[KeyPgOpArrayIndex|Operator () (Array index)]]##
- ##[[KeyPgOpAdd|Operator + (Add)]]##
- ##[[KeyPgOpSubtract|Operator - (Subtract)]]##
- [[CatPgOpPoint|Pointer Operators]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **[]** ( [[KeyPgByref byref]] //lhs// [[KeyPgAs as]] //T// [[KeyPgPointer pointer]], [[KeyPgByref byref]] //rhs// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgByrefFunction byref]] [[KeyPgAs as]] //T//
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf *]](//lhs// [[KeyPgOpAdd +]] //rhs//)##"; both do exactly the same thing. Like pointer arithmetic, any type of ##[[KeyPgPointer Pointer]]## can be indexed except for an ##[[KeyPgAny Any]]## ##[[KeyPgPointer Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
- [[ProPgPtrArithmetic Pointer Arithmetic]]
- ##[[KeyPgOpValueOf Operator * (Value of)]]##
- ##[[KeyPgOpArrayIndex Operator () (Array index)]]##
- ##[[KeyPgOpAdd Operator + (Add)]]##
- ##[[KeyPgOpSubtract Operator - (Subtract)]]##
- [[CatPgOpPoint Pointer Operators]]


Revision [17384]

Edited on 2014-11-26 11:08:56 by CountingPine [Link to ProPgPtrArithmetic]
Additions:
- [[ProPgPtrArithmetic Pointer Arithmetic]]


Revision [17053]

Edited on 2014-04-27 03:42:39 by FxMwikki [Add operator [] overloading]
Additions:
This operator can be overloaded for user-defined types.


Revision [16582]

Edited on 2013-02-04 00:57:55 by CountingPine [Link to Operator * (Value of)]
Additions:
- ##[[KeyPgOpValueOf Operator * (Value of)]]##


Revision [16579]

Edited on 2013-02-04 00:38:23 by CountingPine [Try to rephrase paragraphs about multiple-indexing for clarity]
Additions:
When indexing a '2-dimensional' pointer (i.e. a ##//T// Ptr Ptr##), the first (leftmost) index is applied before the second: For example, ##//Pt//[//I1//][//I2//]## = ##*(//Pt//[//I1//] + //I2//)## = ##*(*(//Pt// + //I1//) + //I2//)##
In general, when using an '//n//-dimensional' pointer: ##//Pt//[//I1//][//I2//].....[//In//]##, the index order (from left to right) corresponds to the dereferencing order.
Deletions:
When using 'nD' pointer (n indexes, with n > 1): Pt[I1][I2].....[In], the indexes order (from left to right) corresponds to the dereferencing order.
Example for '2D' pointer: Pt[I1][I2] = *(Pt[I1] + I2) = *(*(Pt + I1) + I2)


Revision [16578]

Edited on 2013-02-04 00:31:49 by CountingPine [Make example match output; formatting]
Additions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf *]](//lhs// [[KeyPgOpAdd +]] //rhs//)##"; both do exactly the same thing. Like pointer arithmetic, any type of ##[[KeyPgPointer Pointer]]## can be indexed except for an ##[[KeyPgAny Any]]## ##[[KeyPgPointer Pointer]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
print p[index];
print
%% 0 1 2 3 4
Deletions:
This operator returns a reference to a value some distance in memory from a base address. It is essentially shorthand for "##[[KeyPgOpValueOf *]](//lhs// [[KeyPgOpAdd +]] //rhs//)##"; both do exactly the same thing. Like pointer arithmetic, any type of ##[[KeyPgPointer POINTER]]## can be indexed except for an ##[[KeyPgAny ANY]]## ##[[KeyPgPointer POINTER]]##. Also, like pointer arithmetic, it is up to the user to make sure meaningful data is being accessed.
print p[index]
%%0 1 2 3 4


Revision [16577]

Edited on 2013-02-04 00:25:16 by CountingPine [Byref Function syntax; link to array indexing / String indexing op (needs an fbdoc-type link because]
Additions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **[]** ( [[KeyPgByref byref]] //lhs// [[KeyPgAs as]] //T// [[KeyPgPointer pointer]], [[KeyPgByref byref]] //rhs// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgByrefFunction byref]] [[KeyPgAs as]] //T//
- ##{{fbdoc item="keyword" value="KeyPgOpStringIndex|Operator [] (String index)"}}##
- ##[[KeyPgOpArrayIndex Operator () (Array index)]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **[]** ( [[KeyPgByref byref]] //lhs// [[KeyPgAs as]] //T// [[KeyPgPointer pointer]], [[KeyPgByref byref]] //rhs// [[KeyPgAs as]] [[KeyPgInteger integer]] ) [[KeyPgAs as]] //T//
~&//Note that **##Operator []## (Pointer index)** returns a reference. See [[CompilerFAQ CompilerFAQ]].//


Revision [15195]

Edited on 2011-08-17 08:59:45 by FxMwikki [Byref Function syntax; link to array indexing / String indexing op (needs an fbdoc-type link because]
Additions:
When using 'nD' pointer (n indexes, with n > 1): Pt[I1][I2].....[In], the indexes order (from left to right) corresponds to the dereferencing order.
Example for '2D' pointer: Pt[I1][I2] = *(Pt[I1] + I2) = *(*(Pt + I1) + I2)
Deletions:
When using a nD pointer (n indexes, with n > 1): Pt[I1][I2].....[In], the indexes order (from left to right) corresponds to the dereferencing order.
Example for a 2D pointer: Pt[I1][I2] = *(Pt[I1] + I2) = *(*(Pt + I1) + I2)


Revision [15194]

Edited on 2011-08-17 08:46:38 by FxMwikki [Byref Function syntax; link to array indexing / String indexing op (needs an fbdoc-type link because]
Additions:
When using a nD pointer (n indexes, with n > 1): Pt[I1][I2].....[In], the indexes order (from left to right) corresponds to the dereferencing order.
Example for a 2D pointer: Pt[I1][I2] = *(Pt[I1] + I2) = *(*(Pt + I1) + I2)


Revision [14399]

Edited on 2009-08-29 21:55:42 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
- New to ""FreeBASIC""
Deletions:
- New to FreeBASIC


Revision [14149]

Edited on 2009-05-28 19:45:50 by LaananFisher [Remove CamelCase links in "New to FreeBASIC"]
Additions:
~&//Note that **##Operator []## (Pointer index)** returns a reference. See [[CompilerFAQ CompilerFAQ]].//
Deletions:
~&//Note that **##Operator []## (Pointer index)** returns a reference. As of 02.27.07, ""FreeBASIC"" syntax does not support returning references. When it does, this syntax will need to be changed.//


Revision [13489]

The oldest known version of this page was created on 2008-07-11 06:30:36 by DoS386 [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode