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
They have explicit distinctions between members and methods, and it's simple to read. Now, see the equivalent Oak code.
// For use in other type definitionsconstDATE_SIZE = 3;typeDate(DATE_SIZE){fnnew() -> Date{return[0,0,0];}fnget_day(self:&Date) -> num{returnself->day }// members as methodsfnmonth(self:&Date) -> &num{returnselfas#}fnday(self:&Date) -> &num{return(self + 1)as#}fnyear(self:&Date) -> &num{return(self + 2)as#}}
See anything significant? The Oak code accomplishes exactly the same thing, but it's utterly massive in comparison.
How about tagged unions? Here is some example rust code.
Of course, there would have to be a lot of accommodations for copy and drop methods when they are added, but they could definitely still be supported with structures and enums.
The text was updated successfully, but these errors were encountered:
Right now, Oak's type system is a bit weird compared to other languages. Take for example, C++ structures:
They have explicit distinctions between members and methods, and it's simple to read. Now, see the equivalent Oak code.
See anything significant? The Oak code accomplishes exactly the same thing, but it's utterly massive in comparison.
How about tagged unions? Here is some example rust code.
To simulate something like tagged unions in Oak, its significantly more difficult.
Another HUGE problem in Oak is the lack of static dispatch: there's absolutely no support for template or type parameters.
These things could easily be abstracted away by a new top-level IR at compile time. The syntax of Oak would be completely changed by this.
Here is some example potential new Oak syntax and its expansion to the current top level IR code.
Becomes:
Of course, there would have to be a lot of accommodations for
copy
anddrop
methods when they are added, but they could definitely still be supported with structures and enums.The text was updated successfully, but these errors were encountered: