In designing a language from scratch, should methods use a self variable to access properties and other methods? Or should they imply their target with .prop? Or should they treat properties as local variables and methods as local functions? I'm currently leaning towards the latter option - i.e. method4/5 below - but I'm not certain about all implications of that choice. The main problem I foresee is that shadowing becomes cumbersome without a dedicated shadow-operator. Am I missing anything crucial?
pseudo code:
implement Type_with_properties {
method1 (self: Type_with_properties, prop: Some_other_type) {
print(self.prop, prop);
self.prop = prop;
self.other_method();
}
method2 (prop: Some_other_type) {
print(SELF.prop, prop);
SELF.prop = prop;
SELF.other_method();
}
method3 (prop: Some_other_type) {
print(.prop, prop);
.prop = prop;
.other_method();
}
method4 (prop`: Some_other_type) { // ` as shadow operator:
print(prop, prop`); // potentially different output
prop = prop`;
other_method();
}
// variation of the previous notation
// but with different syntactic sugar:
method5 (:prop) {
print(prop, prop); // identical
other_method();
}
}