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

Nil lifting for method calls #133

Closed
jclark opened this issue May 19, 2019 · 4 comments
Closed

Nil lifting for method calls #133

jclark opened this issue May 19, 2019 · 4 comments
Labels
design/incomplete Part of design not yet worked out status/pending Design is agreed and waiting to be added
Milestone

Comments

@jclark
Copy link
Collaborator

jclark commented May 19, 2019

We need to make nil lifting for method calls work well with the desugaring of method calls for non-objects into functions described in #111.

@jclark jclark added design/incomplete Part of design not yet worked out status/discuss Needs discussion outside github comments labels May 19, 2019
@jclark jclark added this to the 2019R2 milestone May 19, 2019
@jclark
Copy link
Collaborator Author

jclark commented May 20, 2019

Also relates to #85, which has to do with nil-lifting generally.

@jclark
Copy link
Collaborator Author

jclark commented May 20, 2019

Suppose we have an object type OT that provides a method foo. Given an expression E of type OT|(), and an expression call E.foo(), there may or may not be a method value:foo that accepts an argument of type (). The fundamental problem is that there are two plausible choices for what E.foo() should do when E results in ():

  • call value:foo( () ), or
  • nil lift i.e. return ()

Every approach has its downside:

  1. Never do nil lifting. So it would be an error if value:foo( () ) is not a valid function cal. This would mean we lose the convenience of nil lifting.
  2. Always do nil lifting. This would result in inconsistent behaviour for expressions of type OT? and any.
  3. Do nil lifting conditionally: i.e. call value:foo( () ) is that is legal, otherwise nil lift. This means that if we add new functions to lang.value which accept a () argument but do not return () with a () argument, we will break code.

@jclark jclark mentioned this issue May 31, 2019
@jclark
Copy link
Collaborator Author

jclark commented Jun 2, 2019

Conclusion today was not to do nil-lifting for either method calls or object field access.

@jclark jclark added status/pending Design is agreed and waiting to be added and removed status/discuss Needs discussion outside github comments labels Jun 2, 2019
@jclark
Copy link
Collaborator Author

jclark commented Jun 3, 2019

This corresponds to how the spec is currently written for method calls.

@jclark jclark closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design/incomplete Part of design not yet worked out status/pending Design is agreed and waiting to be added
Projects
None yet
Development

No branches or pull requests

1 participant