-
Notifications
You must be signed in to change notification settings - Fork 1
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
untyped magic #33
Comments
JS target uses the same approach: |
|
So should new generator support |
I guess we should still support |
So what's the approved alternative? ) |
I don't really have a strong opinion about that, any normal field call will do. |
I think |
Additionally |
In python we have |
I don't really see how it would make much difference compared to |
Yes but this allows us to introduce some |
Have you guys looked at the solutions used by Typescript and scala.js for this general problem of calling into untyped external code? I know they're JS rather than PHP, but it's the same basic issue. They let you define a typed interface, like this scala.js for the Google maps JS lib:
I know it seems a bit of a pain, but they don't take long to knock up, and Typescript has a cool shared repo of these interfaces for all kinds of JS libraries. You can then call methods and create objects from those JS libraries in a type-safe way, and the generated code is optimal too. |
untyped is my biggest pain point currently (I'm writing a Wordpress plugin in Haxe and need to call into Wordpress functions loads) and I'd love to see it get a lot slicker. To take another example from how scalajs handles things, if you don't setup an interface (as above), you can just do this:
Admittedly there's no more type-safety than with untyped, and scala.js has no idea whether some_external_func exists and how many args it takes, I just think it's a bit easier to read and write that than:
I can more easily see the arguments, at least. Maybe this syntactic sugar is possible? |
Haxe has the same concept called externs: https://haxe.org/manual/lf-externs.html |
Ah amazing, thank you. I'm very new to Haxe, these look great. |
Here is an example: https://github.com/RealyUniqueName/haxe/blob/php7/std/php7/reflection/ReflectionProperty.hx |
Implemented |
As I wrote before, I remember @Simn was not so happy with
untyped __php__
and the like.@Simn: Are there better ways to handle this, maybe already implemented in the newer generators (python, lua)?
The text was updated successfully, but these errors were encountered: