One of the new features provided by Ring 1.25 (GitHub) is Translating Internal Identifiers
The identifiers that can be translated are:
This
Self
Super
Main
Init
Operator
BraceStart
BraceExprEval
BraceError
BraceEnd
Note
Ring defines keywords that act as wrappers for these identifiers (i.e., when the Ring Parser encounters such a keyword, it is converted into the corresponding identifier).
Example:
new point { x=10 y=20 z=30 ? self }
ChangeRingKeyword self my
new point { x=10 y=20 z=30 ? my }
# Since self is an identifier (not a real keyword)
# We can use (self) or (my) at the same time
new point { x=100 y=200 z=300 ? my ? self }
new point { x=1000 y=2000 z=3000 test()}
class parent
func test
? "Parent - Test()"
class point from parent
x y z
func test
ChangeRingKeyword this mypoint
? this
? mypoint
ChangeRingKeyword super father
super.test()
father.test()
Output:
x: 10
y: 20
z: 30
x: 10
y: 20
z: 30
x: 100
y: 200
z: 300
x: 100
y: 200
z: 300
x: 1000
y: 2000
z: 3000
x: 1000
y: 2000
z: 3000
Parent - Test()
Parent - Test()