Let me know if I should post such things elsewhere.
Code: Select all
; This program does not run, it is an example of a capability I'd like to see implemented.
global Var1 := "Here is a super global string."
Var4 := "Here is a global string."
MyClass.MyMethod(<#>, ByRef Var4)
class MyClass
{
static Var2 := "Here is a class static string."
MyMethod(WhichOne := 1, ByRef MyVar)
{
static Var3 := "Here is a method string."
ThisVar #= WhichOne = 1 ? Var1 : WhichOne = 2 ? This.Var2 : WhichOne = 3 ? Var3 : MyVar
; where #= causes ThisVar to be whichever var# is assigned to it.
ThisVar := "This" . SubStr(ThisVar, 10, StrLen(ThisVar) - 10) . " is in Var" . WhichOne
; if WhichOne = 1, Var1 will now be "This super global string is in Var1"
; if WhichOne = 2, Var2 will now be "This class static string is in Var2"
; if WhichOne = 3, Var3 will now be "This method string is in Var3"
; if WhichOne = 4, Var4 will now be "This global string is in Var4"
; One of my favorite languages was capable of this and it was quite handy.
; Of course the way it stored its variables made it easy:
; Var# pointed to a permanent location for that variable's descriptor.
; A descriptor contained, among other things, the address of the actual variable's
; contents and its length. The descriptors below are shortend to contain only
; the address of the actual variable's contents and its length.
; For example, in memory location:
; 10000 - 10003: Address to Var1's contents: 58000 initially.
; 10004 - 10007: Var1's content length plus terminating zero (0) byte: 31 initially.
; 10008 - 10011: Address to Var2.
; 10012 - 10015: Var2's length.
; 10016 - 10019: Address to Var3.
; 10020 - 10023: Var3's length.
; ..... - .....: Other descriptors and data and code.
; 58000 - 58030: Contents of Var1 initially: "Here is a super global string."0
;
; Wherever Var1 is used, Var1 points to the descriptor located at 10000.
; ThisVar #= Var1 simply causes ThisVar to point to the descriptor located at 10000.
; And now Var1 and ThisVar are the same variable.
; It doesn't matter if the actual variable's content address changes, the
; descriptor address never changes and allways contains the address
; to the actual variable's contents.
;
; The above assumes ASCII mode, that is, one byte of memory per character.
}
}