Skip to content

update spec on evaluation order of deferred checks #3764

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

Open
sigmundch opened this issue Jan 18, 2018 · 5 comments
Open

update spec on evaluation order of deferred checks #3764

sigmundch opened this issue Jan 18, 2018 · 5 comments
Labels
specification technical-debt Dealing with a part of the language which needs clarification or adjustments

Comments

@sigmundch
Copy link
Member

I couldn't find in the spec a lot of details explaining deferred checks. The program below:

import 'a.dart' deferred as a;

main() {
  var x = 1;
  try {
    a.foo(x = 2);
  } finally {
    print(x);
}

We will be injecting a check that "a" is loaded before we allow the call to "foo". This check can be injected before or after arguments are evaluated to a value. This is implemented differently in dart2js and the VM: the example above prints 1 in dart2js and 2 in the vm.

In Dart 1 I'd have said we should implement the VM semantics. However, In Dart2 I believe we want the dart2js semantics instead: this matches the left-to-right consistency rule that we are adopting for Dart 2. I'm about to implement that in the FE at this moment.

@leafpetersen @lrhn @floitschG - can you clarify? would it be possible to explicitly call this out in the spec?

Related issue dart-lang/sdk#27577

@leafpetersen
Copy link
Member

Makes sense to me. I believe we've discussed making deferred loading an web only feature: whether we do so or not, I think it is largely driven by the needs of the web.

@eernstg
Copy link
Member

eernstg commented Jan 18, 2018

Yes, I think it makes sense to specify the evaluation order more precisely also in this case, and I agree that it should follow the left-to-right rule you mention consistently. @lrhn?

@lrhn
Copy link
Member

lrhn commented Jan 18, 2018

The a.foo should fail at the time where foo is looked up in a (and a isn't loaded).
So, yes, it should follow the evaluation order of the expression. In this case, it means before evaluating arguments.

@eernstg eernstg self-assigned this Jan 18, 2018
@eernstg
Copy link
Member

eernstg commented Jan 18, 2018

OK, decided: The language specification should specify the left-to-right evaluation order (in the example: the arguments should not be evaluated before failing). This issue serves to get that done. It would also serve as a justification for implementing it that way now.

@sigmundch
Copy link
Member Author

Fantastic! Thanks for the quick turn around on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
specification technical-debt Dealing with a part of the language which needs clarification or adjustments
Projects
Development

No branches or pull requests

4 participants