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

Mark native properties (typed as plain fields) as having side-effectful reads. #8226

Closed
back2dos opened this issue Apr 29, 2019 · 6 comments · Fixed by #8338
Closed

Mark native properties (typed as plain fields) as having side-effectful reads. #8226

back2dos opened this issue Apr 29, 2019 · 6 comments · Fixed by #8338
Assignees
Milestone

Comments

@back2dos
Copy link
Member

On platforms that support native properties, getters may cause side effects, but because we type it as default access, the compiler may choose to eliminate them.

The most prominent case I can think of is the DOM API, where it's common practice to query layout properties to cause a DOM reflow. I would suggested @:pure(false) to be in line with methods, but anything else will do just fine ;)

@Simn Simn added this to the Release 4.0 milestone May 17, 2019
@Simn
Copy link
Member

Simn commented May 17, 2019

Is this a matter of adding @:pure(false) to externs or do we have to support something in the compiler first?

Either way, we should address this for 4.0 because it has the potential to cause regressions.

@Simn Simn self-assigned this May 17, 2019
@back2dos
Copy link
Member Author

Well, it seems like the compiler is very unimpressed with @:pure(false) on fields. FWIW though, it's not a regression.

@RealyUniqueName
Copy link
Member

Is it only applicable to extern classes? Is possible to somehow define such properties in non-extern classes?

@nadako
Copy link
Member

nadako commented May 17, 2019

I mean you can of course hack in some craziness, but in general Haxe fields are just fields :)

@back2dos
Copy link
Member Author

Well, I do actually have a use case for non-extern classes, but today I don't feel like reopening the old debates on what you should and shouldn't do with properties ;)

My primary concern is that idiomatic code for DOM APIs has its behavior broken through optimization. People can of course just learn that, but if removing this hurdle is easy enough, I would much prefer to just do it.

@nadako
Copy link
Member

nadako commented May 18, 2019

Yeah I agree about DOM stuff and I can imagine some interesting use-cases with actual Haxe properties, but I was talking about plain Haxe non-extern fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants