Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add classes and objects #537

Closed
ghost opened this issue Jul 14, 2022 · 5 comments
Closed

Add classes and objects #537

ghost opened this issue Jul 14, 2022 · 5 comments
Labels
feature request New feature or request

Comments

@ghost
Copy link

ghost commented Jul 14, 2022

How do I modify the compiler to add a class type and an Object type.

@ghost
Copy link
Author

ghost commented Jul 14, 2022

And of course the new keyword and the constructor feature.

@lenscas
Copy link
Contributor

lenscas commented Jul 14, 2022

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 #200

@ghost
Copy link
Author

ghost commented Jul 14, 2022

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.

@lenscas
Copy link
Contributor

lenscas commented Jul 14, 2022

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

@hishamhm
Copy link
Member

Closing this as a duplicate of #97 — there are no immediate plans to add class and object primiteves, but they're not discarded either.

@hishamhm hishamhm added the feature request New feature or request label Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants