You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add native methods to the language. They have a return value and can be called explicitly (unlike implementations).
entity Int:
int n
bool even = self.is_even()
end
method is_even: bool for Int:
return self.n % 2 == 0 # 1 return statement per method, conventionally lexically last in the block but not strictly required
end
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:
have the ability to return entities for methods. This then also raises the question: do we need methods or wouldn't functions be much more useful. Something like a plugin call, but defined in the language
Introduce a concept of in and out parameters. It seems that some database have this in stored procedures and in the swift language of apple
Description
Add native methods to the language. They have a return value and can be called explicitly (unlike implementations).
Open questions
The text was updated successfully, but these errors were encountered: