-
Notifications
You must be signed in to change notification settings - Fork 281
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
Support for type annotations on non-local object properties of a Class #331
Comments
One problem here is that your first code snippet defines an implicit class for |
good point - how does reflection work if not using type annotations? class BugReport {
regularVar: String = ""
internalObj {
willWork = regularVar
}
} Could the same be done for internal classes? If not, could it just generate "random" classname for the internal class? |
We don't have any plans on supporting type annotations on non-local object properties. One feature that might help you is anonymous classes; e.g.
It's still unclear if we'd ever support this, but there's some valid use-cases for it. For example, for easier interop with external schema definitions (e.g. JSON Schema) |
@etaham |
I'm trying to balance two goals:
Does this make sense? How are others thinking about this? |
I think you've already found the right solution. BugReport.pkl
|
That works - it's just a little inconsistent. Thank you! |
[Feature Request]
I'm trying to organize the contents of a class and running into an error around type annotations. Here is the code:
Running
pkl eval bugReport.pkl -f yaml
yields the following error:Something that does work is to define a new class for internalObj, but then you can't take advantage of late binding to set defaults without slightly less natural code (where the definition and defaults needs to be defined separately). This works, but notice that the default is specified outside the class definition.
Ask would be to make the first code snippet work.
Thank you!
Eli
The text was updated successfully, but these errors were encountered: