Revision history for KeyPgOpLet


Revision [22585]

Last edited on 2019-02-26 09:10:03 by fxm [Suppressed reference to fbc version 0.90]
Additions:
//lhs// **=>** //rhs//
Deletions:
//lhs// **=>** //rhs// (from fbc version 0.90)


Revision [22374]

Edited on 2018-08-28 14:15:18 by fxm [Enum does not support member operators]
Additions:
- None.
Deletions:
- None


Revision [22372]

Edited on 2018-08-28 14:08:54 by fxm [Enum does not support operators]
Additions:
{ [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] } //typename//
name of the ##[[KeyPgType|Type]]##, ##[[KeyPgClass|Class]]##, or ##[[KeyPgUnion|Union]]##.
Deletions:
{ [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] | [[KeyPgEnum|Enum]] } //typename//
name of the ##[[KeyPgType|Type]]##, ##[[KeyPgClass|Class]]##, ##[[KeyPgUnion|Union]]##, or ##[[KeyPgEnum|Enum]]##


Revision [21372]

Edited on 2016-04-15 08:21:24 by fxm [Added link to 'Coercion and Conversion']
Additions:
- [[ProPgDataConversion|Coercion and Conversion]]


Revision [21041]

Edited on 2016-03-13 06:56:21 by fxm [Formatting]
Additions:




Revision [20391]

Edited on 2016-02-10 16:04:53 by DkLwikki [Update link format]
Additions:
Indicates the assignment operator when overloading [[KeyPgOpAssignment|Operator = (Assignment)]]
{ [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] | [[KeyPgEnum|Enum]] } //typename//
[[KeyPgDeclare|declare]] [[KeyPgOperator|operator]] **Let** ( [ [[KeyPgByref|byref]] | [[KeyPgByval|byval]] ] //rhs// [[KeyPgAs|as]] [[DataType|datatype]] )
End { [[KeyPgType|Type]] | [[KeyPgClass|Class]] | [[KeyPgUnion|Union]] }
[[KeyPgOperator|operator]] //typename//.**Let** ( [ [[KeyPgByref|byref]] | [[KeyPgByval|byval]] ] //rhs// [[KeyPgAs|as]] [[DataType|datatype]] )
name of the ##[[KeyPgType|Type]]##, ##[[KeyPgClass|Class]]##, ##[[KeyPgUnion|Union]]##, or ##[[KeyPgEnum|Enum]]##
##**Let**## is used to overload the ##{{fbdoc item="keyword" value="KeyPgOpAssignment|Operator =[>] (Assignment)"}}## operator and to distinguish it from the comparison operator ##[[KeyPgOpEqual|Operator = (Equal)]]##.
- In the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, this operator cannot be overloaded.
- In the //[[CompilerOptlang|-lang qb]]// and //[[CompilerOptlang|-lang fblite]]// dialects, an assignment expression can be preceded by the ##[[KeyPgLet|Let]]## keyword.
- ##[[KeyPgLet|Let]]##
- ##[[KeyPgOpLetlist|Operator Let() (Assignment)]]##
- ##[[KeyPgOpEqual|Operator = (Equal)]]##
Deletions:
Indicates the assignment operator when overloading [[KeyPgOpAssignment Operator = (Assignment)]]
{ [[KeyPgType Type]] | [[KeyPgClass Class]] | [[KeyPgUnion Union]] | [[KeyPgEnum Enum]] } //typename//
[[KeyPgDeclare declare]] [[KeyPgOperator operator]] **Let** ( [ [[KeyPgByref byref]] | [[KeyPgByval byval]] ] //rhs// [[KeyPgAs as]] [[DataType datatype]] )
End { [[KeyPgType Type]] | [[KeyPgClass Class]] | [[KeyPgUnion Union]] }
[[KeyPgOperator operator]] //typename//.**Let** ( [ [[KeyPgByref byref]] | [[KeyPgByval byval]] ] //rhs// [[KeyPgAs as]] [[DataType datatype]] )
name of the ##[[KeyPgType Type]]##, ##[[KeyPgClass Class]]##, ##[[KeyPgUnion Union]]##, or ##[[KeyPgEnum Enum]]##
##**Let**## is used to overload the ##{{fbdoc item="keyword" value="KeyPgOpAssignment|Operator =[>] (Assignment)"}}## operator and to distinguish it from the comparison operator ##[[KeyPgOpEqual Operator = (Equal)]]##.
- In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, this operator cannot be overloaded.
- In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, an assignment expression can be preceded by the ##[[KeyPgLet Let]]## keyword.
- ##[[KeyPgLet Let]]##
- ##[[KeyPgOpLetlist Operator Let() (Assignment)]]##
- ##[[KeyPgOpEqual Operator = (Equal)]]##


Revision [17807]

Edited on 2015-09-29 15:14:38 by FxMwikki ['=>' is an alternative syntax for the assignment operator]
Additions:
##//or//##
//lhs// **=>** //rhs// (from fbc version 0.90)
##**Let**## is used to overload the ##{{fbdoc item="keyword" value="KeyPgOpAssignment|Operator =[>] (Assignment)"}}## operator and to distinguish it from the comparison operator ##[[KeyPgOpEqual Operator = (Equal)]]##.
##//lhs// **=[>]** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the ##**Let**## operator procedure defined in ##//typename//##.
This includes the case of an object returned from a function by value, by using ##**Function** =[>] //rhs//## (or ##//function_identifier// =[>] //rhs//##) assignment.
- ##{{fbdoc item="keyword" value="KeyPgOpAssignment|Operator =[>] (Assignment)"}}##
Deletions:
##**Let**## is used to overload the ##[[KeyPgOpAssignment Operator = (Assignment)]]## operator and to distinguish it from the comparison operator ##[[KeyPgOpEqual Operator = (Equal)]]##.
##//lhs// **=** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the ##**Let**## operator procedure defined in ##//typename//##.
This includes the case of an object returned from a function by value, by using ##**Function** = //rhs//## (or ##//function_identifier// = //rhs//##) assignment.
- ##[[KeyPgOpAssignment Operator = (Assignment)]]##


Revision [17072]

Edited on 2014-05-01 09:40:05 by FxMwikki [Assigning one array is not supported presently]
Additions:
Assigning one array is not supported presently.


Revision [17070]

Edited on 2014-04-29 16:37:40 by FxMwikki [Typo]
Additions:
##//lhs// **=** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the ##**Let**## operator procedure defined in ##//typename//##.
Deletions:
##//lhs// **=** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the ##**Let**## operator procedure defined int ##//typename//##.


Revision [16978]

Edited on 2013-11-21 14:54:26 by FxMwikki [Added details on invoking the Let operator]
Additions:
This includes the case of an object returned from a function by value, by using ##**Function** = //rhs//## (or ##//function_identifier// = //rhs//##) assignment.


Revision [16527]

Edited on 2013-01-04 05:54:11 by FxMwikki [Added text explaining when and how use the Let operator, with a consistent example]
Additions:
##//lhs// **=** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the ##**Let**## operator procedure defined int ##//typename//##.
An operator ##**Let**## (assign) must be defined if the shallow implicit copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the implicit assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).
Note: It is safe to do a check for self-assignment at the top of the ##**Let**## body (by comparing the address of implicit 'this' instance with the address of 'rhs' parameter) to avoid object destruction if previously allocated memory is first deallocated (see example below).
Deletions:
##//lhs// **=** //rhs//## will assign the ##//rhs//## to ##//lhs//## by invoking the **Let** operator procedure defined int ##//typename//##.
An operator Let (assign) must be defined if the shallow implicit copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the implicit assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).
Note: It is safe to do a check for self-assignment at the top of the Let body (by comparing the address of implicit 'this' instance with the address of 'rhs' parameter) to avoid object destruction if previously allocated memory is first deallocated (see example below).


Revision [16526]

Edited on 2013-01-04 03:29:26 by FxMwikki [Added text explaining when and how use the Let operator, with a consistent example]
Additions:
Note: It is safe to do a check for self-assignment at the top of the Let body (by comparing the address of implicit 'this' instance with the address of 'rhs' parameter) to avoid object destruction if previously allocated memory is first deallocated (see example below).
Deletions:
Note: It is safe to do a check for self-assignment at the top of the Let body (by comparing the address of implicit 'this' instance with the address of 'rhs' parameter) to avoid object destruction if previously allocated memory is first deallocated (see example below).


Revision [16525]

Edited on 2013-01-04 02:56:50 by FxMwikki [Added text explaining when and how use the Let operator, with a consistent example]
Additions:
An operator Let (assign) must be defined if the shallow implicit copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the implicit assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).
Deletions:
An operator Let (assign) must be defined if the shallow default copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the default assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).


Revision [16524]

Edited on 2013-01-03 15:00:50 by FxMwikki [Added text explaining when and how use the Let operator, with a consistent example]
Additions:
An operator Let (assign) must be defined if the shallow default copy is not sufficient. This happens in cases when the object manages dynamically allocated memory or other resources which need to be specially copied (for example if a member pointer points to dynamically allocated memory, the default assignment operator will simply copy the pointer value instead of allocate memory and then perform the copy of data).
Note: It is safe to do a check for self-assignment at the top of the Let body (by comparing the address of implicit 'this' instance with the address of 'rhs' parameter) to avoid object destruction if previously allocated memory is first deallocated (see example below).
Type UDT
Public:
Declare Constructor (Byval zp As Const Zstring Ptr) ''constructor with string initializer
Declare Operator Let (Byref rhs As UDT) ''operator Let (assignment)
Declare Function getString () As String ''function to get string
Declare Destructor () ''destructor
Private:
Dim zp As Zstring Ptr ''private pointer to avoid direct access
End Type
Constructor UDT (Byval zp As Const Zstring Ptr)
This.zp = Callocate(Len(*zp) + 1)
*This.zp = *zp
End Constructor
Operator UDT.Let (Byref rhs As UDT)
If @This <> @rhs Then '' check for self-assignment to avoid object destruction
Deallocate(This.zp)
This.zp = Callocate(Len(*rhs.zp) + 1)
*This.zp = *rhs.zp
End If
End Operator
Function UDT.getString () As String
Return *This.zp
End Function
Destructor UDT ()
Deallocate(This.zp)
End destructor
Dim u As UDT = UDT("")
u = Type<UDT>("Thanks to the overloading operator Let (assign)")
Print u.getString
Sleep
Thanks to the overloading operator Let (assign)
Deletions:
type T
x as integer
y as integer
declare operator let( byref rhs as T )
end type
operator T.let( byref rhs as T )
x = rhs.x
y = rhs.y
end operator
dim a as T = ( 5, 7 )
dim b as T
'' Do the assignment invoking the LET
'' operator procedure
b = a
print "a.x = "; a.x
print "a.y = "; a.y
print
print "b.x = "; b.x
print "b.y = "; b.y
a.x = 5
a.y = 7
b.x = 5
b.y = 7


Revision [13717]

Edited on 2008-09-11 12:43:58 by CountingPine [Misc edits]
Additions:
Indicates the assignment operator when overloading [[KeyPgOpAssignment Operator = (Assignment)]]
'' Do the assignment invoking the LET
- In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, this operator cannot be overloaded.
- In the //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, an assignment expression can be preceded by the ##[[KeyPgLet Let]]## keyword.
- ##[[KeyPgOpLetlist Operator Let() (Assignment)]]##
- ##[[KeyPgOpAssignment Operator = (Assignment)]]##
Deletions:
Indicates the assignment operator when overloading [[KeyPgOpAssignment Operator = (Assignement]]
'' Do the assinment invoking the LET
- In the //[[CompilerOptlang -lang qb]]// dialect, this operator cannot be overloaded.
- In the //[[CompilerOptlang -lang qb]]// dialect, an assignment expression can be preceded by the ##[[KeyPgLet Let]]## keyword.
- ##[[KeyPgOpEqual Operator Let() (Assignment)]]##
- ##[[KeyPgOpEqual Operator = (Assignment)]]##


Revision [12400]

The oldest known version of this page was created on 2008-01-18 14:21:39 by JeffMarshall [Misc edits]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode