langs a-z
This commit is contained in:
parent
db842d013d
commit
d066446780
11389 changed files with 98361 additions and 1020 deletions
|
|
@ -0,0 +1,3 @@
|
|||
#i_Const1 = 11
|
||||
#i_Const2 = 3.1415
|
||||
#i_Const3 = "A'm a string"
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
;Enforced immutability Variable-Class
|
||||
|
||||
Interface PBVariable ; Interface for any value of this type
|
||||
Get() ; Get the current value
|
||||
Set(Value.i) ; Set (if allowed) a new value in this variable
|
||||
ToString.s() ; Transferee the value to a string.
|
||||
Destroy() ; Destructor
|
||||
EndInterface
|
||||
|
||||
Structure PBV_Structure ; The *VTable structure
|
||||
Get.i
|
||||
Set.i
|
||||
ToString.i
|
||||
Destroy.i
|
||||
EndStructure
|
||||
|
||||
Structure PBVar
|
||||
*VirtualTable.PBV_Structure
|
||||
Value.i
|
||||
EndStructure
|
||||
|
||||
;- Functions for any PBVariable
|
||||
Procedure immutable_get(*Self.PBVar)
|
||||
ProcedureReturn *Self\Value
|
||||
EndProcedure
|
||||
|
||||
Procedure immutable_set(*Self.PBVar, N.i)
|
||||
ProcedureReturn #False
|
||||
EndProcedure
|
||||
|
||||
Procedure.s immutable_ToString(*Self.PBVar)
|
||||
ProcedureReturn Str(*Self\Value)
|
||||
EndProcedure
|
||||
|
||||
Procedure DestroyImmutabe(*Self.PBVar)
|
||||
FreeMemory(*Self)
|
||||
EndProcedure
|
||||
|
||||
;- Init an OO-Table
|
||||
DataSection
|
||||
VTable:
|
||||
Data.i @immutable_get()
|
||||
Data.i @immutable_set()
|
||||
Data.i @immutable_ToString()
|
||||
Data.i @DestroyImmutabe()
|
||||
EndDataSection
|
||||
|
||||
;- Create-Class
|
||||
Procedure CreateImmutabe(Init.i=0)
|
||||
Define *p.PBVar
|
||||
*p=AllocateMemory(SizeOf(PBVar))
|
||||
*p\VirtualTable = ?VTable
|
||||
*p\Value = Init
|
||||
ProcedureReturn *p
|
||||
EndProcedure
|
||||
|
||||
;- **************
|
||||
;- Test the Code
|
||||
|
||||
;- Initiate two Immutabe variables
|
||||
*v1.PBVariable = CreateImmutabe()
|
||||
*v2.PBVariable = CreateImmutabe(24)
|
||||
|
||||
;- Present therir content
|
||||
Debug *v1\ToString() ; = 0
|
||||
Debug *v2\ToString() ; = 24
|
||||
|
||||
;- Try to change the variables
|
||||
*v1\Set(314) ; Try to change the value, which is not permitted
|
||||
*v2\Set(7)
|
||||
|
||||
; Present the values again
|
||||
Debug Str(*v1\Get()) ; = 0
|
||||
Debug Str(*v2\Get()) ; = 24
|
||||
|
||||
;- And clean up
|
||||
*v1\Destroy()
|
||||
*v2\Destroy()
|
||||
Loading…
Add table
Add a link
Reference in a new issue