Closed ghost closed 2 years ago
And of course the new keyword and the constructor feature.
Records are what Teal uses to create "classes", what would be the benefit of the new keyword?
Remember, Lua doesn't have classes, if you want inheritance you have to set those systems up yourself in lua. There is an entire discussion on how teal should deal with it at https://github.com/teal-language/tl/issues/200
Because adding new types reduces the number of errors raised by using and creating OOP programming on tl.Adding new keywords makes the construction of the OOP programming system simpler.
again, records are used to create new types. They will act as classes once/if a good model on how to do inheritance in teal is agreed upon. (Read the linked issue). The only difference between records and classes are their names.
new
doesn't really do anything besides calling the constructor, you don't need the keyword new
for that. Just create static functions that return the type. That is all the new Type()
thing abstracts away. As an example, F# code doesn't need the new
keyword. If I want to instance something it is just Type()
and yet it works perfectly fine with C# types.
Now, there might be a reason to add new
depending on the kind of OOP style teal ends up going with, but that is probably better discussed in #200
Closing this as a duplicate of #97 — there are no immediate plans to add class and object primiteves, but they're not discarded either.
How do I modify the compiler to add a class type and an Object type.