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

Support kwargs in method calls #440

Merged
merged 27 commits into from
Sep 22, 2020
Merged

Support kwargs in method calls #440

merged 27 commits into from
Sep 22, 2020

Conversation

leina05
Copy link
Contributor

@leina05 leina05 commented Sep 18, 2020

PR checklist:

  • Added changelog entry.
  • Ruby tests
  • Rust integration tests
  • Check for no kwargs in Java calls
  • Check for no kwargs in Javascript calls
  • Check for no kwargs in Rust calls

@leina05 leina05 force-pushed the leina/ship_mixed_args branch from 8981e4f to e00f95d Compare September 18, 2020 21:42
@leina05 leina05 mentioned this pull request Sep 18, 2020
6 tasks
Copy link
Contributor

@plotnick plotnick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modulo fixing the tests and the minor suggestions, this looks great.

polar-core/src/rewrites.rs Outdated Show resolved Hide resolved
polar-core/src/rewrites.rs Outdated Show resolved Hide resolved
polar-core/src/polar.lalrpop Show resolved Hide resolved
languages/ruby/lib/oso/polar/query.rb Show resolved Hide resolved
polar-core/src/vm.rs Outdated Show resolved Hide resolved
@@ -181,14 +181,6 @@ BuiltinOperator: Operator = {
};

New: Value = {
// Keyword argument constructor.
"new" <literal:Spanned<InstanceLiteralTerm>> => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rm the definition of InstanceLiteralTerm on 166?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait... doesn't that mean we can completely get rid of the whole <"Pattern">? (Not for this PR, to verify later!). That would be nice.

@@ -264,7 +256,7 @@ Exp10<T>: Term = {
}

CallTerm: Value = {
<SimpleCall>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there might be some additional cleanup of SimpleCall stuff we could do in this file. I'm not sure why Value still accepts a SimpleCall on 491:

pub Value: Value = {
    <Number>,
    <PolarString>,
    <Boolean>,
    <Variable>,
    <DictionaryTerm>,
    <BuiltinOperation>,
    <RewrittenOperation>,
    <SimpleCall>,
    <List<"Term">>,
};

or why we couldn't just collapse the declaration of SimpleCall into Call now that we don't need to refer to SimpleCall separately

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wait is the SimpleCall stuff still necessary since we parse Polar predicates (rule heads) the same as method/constructor calls?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but wait that wouldn't make sense either since (I think) the param: Specializer fields in a Polar predicate require different semantics than method calls, which require all kwargs to be at the end of the arglist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can kill SimpleCall and fold its cases into Call. Thanks for catching this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Word of caution: we do support prolog-style person("sam") = person(name) style unification, which is possibly what this syntax is referring to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimpleCall is used for Polar predicates... I don't think it can be folded into Call

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need it to be separate because of specializers, as Gabe pointed out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plotnick and I talked about this -- we use ParameterList to capture the param: Specializer case in rule heads. We folded SimpleCall into Call and everything seems kosher.

@gj gj marked this pull request as ready for review September 21, 2020 23:20
languages/js/src/Polar.test.ts Outdated Show resolved Hide resolved
languages/js/src/Polar.test.ts Outdated Show resolved Hide resolved
@gj
Copy link
Member

gj commented Sep 21, 2020

@leina05 to update docs as a follow-up


- summary of breaking change
The former accepted positional arguments, and the latter accepted keyword
arguments. In this release, the two forms have combined their powers, and
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

@plotnick plotnick merged commit 072a0e3 into main Sep 22, 2020
@plotnick plotnick deleted the leina/ship_mixed_args branch September 22, 2020 01:20
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 this pull request may close these issues.

4 participants