Open sanderr opened 5 months ago
I think the bigger change in the example is having a default that is a full dyamic expression.
Everything else could be defined as syntactic sugar on top of existing things?
entity Method:
end
Method.self [1] -- SelfType
Method(self=myself)
implement Method using implementation_for_it
Interesting suggestion, definitely worth consideration.
I am not entirely sure yet how useful this is and why it is better than:
entity Int:
int n
bool even
end
implementation is_even for Int:
self.even = self.n % 2 == 0
end
However, there is a pattern that we use more often for which this is a start of an improvement. We often "abuse" entity to calculate certain values, often more than one. Something like:
entity Test:
string a
string b
string c
string d
string e
end
implementation x for Test:
self.d = ... # both use a, b, c to calculate d and e
self.e = ...
end
In this case a, b and c are the argument and d and e are the return values. I see two main options for this:
Description
Add native methods to the language. They have a return value and can be called explicitly (unlike implementations).
Open questions