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

Added semantic check for calls to s.bag() from a UDF of s.updateWith* #85

Merged

Conversation

ggevay
Copy link
Contributor

@ggevay ggevay commented Oct 19, 2015

This is solving the first issue in #84. I implemented what I wrote in the comment there.

(This PR is on top of the commit of #83. I will rebase this, after that is merged.)

@ggevay ggevay force-pushed the semantic-check-stateful-udf-bag-access branch 3 times, most recently from 5376edc to 9d0dbda Compare October 20, 2015 08:22
@ggevay
Copy link
Contributor Author

ggevay commented Oct 20, 2015

I did some minor modifications on the PR:

  • I factored out the checks in ComprehensionAnalysis to a function.
  • whitespace changes

@ggevay ggevay force-pushed the semantic-check-stateful-udf-bag-access branch 2 times, most recently from 48866f2 to b257cd5 Compare October 20, 2015 11:59

class InvalidProgramException(message: String = null, cause: Throwable = null) extends Exception(message, cause) {}

class StatefulAccessedFromUdfException()
Copy link
Contributor

Choose a reason for hiding this comment

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

Exceptions can be defined in the api package.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I have moved it there.

@aalexandrov aalexandrov modified the milestone: Oct 2015 Oct 20, 2015
@aalexandrov aalexandrov self-assigned this Oct 20, 2015
@@ -241,16 +242,19 @@ private[emma] trait ComprehensionAnalysis
// stateful.updateWithZero(udf)
case q"${updateWithZero @ Select(ident @ Ident(_), _)}[$_]($udf)"
if updateWithZero.symbol == api.updateWithZero =>
CheckForStatefulAccessedFromUdf(ident, udf)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the semantics checks should be implemented as a separate set of traversers chained together via the ->> combinator (similarly to the normalization chain).

It will also allow us to keep things clearly separated in the long run.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would have the drawback that some of the functionality of comprehend would be duplicated. I mean, there would be a similar match with the same cases. Do you think this is worth it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, there will be some duplication, but on the other hand we cleaner code and separation of concerns.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer if the checks are added as separate functions and chain together in a similar way as the normalize* functions (can happen before the normalization phase).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I will do it that way then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@ggevay ggevay force-pushed the semantic-check-stateful-udf-bag-access branch 4 times, most recently from 6eb633b to 8768204 Compare October 21, 2015 15:44
@aalexandrov
Copy link
Contributor

Thanks, I'll merge this in the next batch.

s <- DataBag(state.get(k(a)).toList)
b <- f(s, a)
} yield b
(k: A => K, f: (S, A) => DataBag[B]): DataBag[B] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

The outer block is redundant.

@aalexandrov aalexandrov assigned joroKr21 and unassigned aalexandrov Oct 23, 2015
@aalexandrov
Copy link
Contributor

I've added two minor remarks regarding code formatting and naming. Otherwise I think this can be merged after #88.

@ggevay ggevay force-pushed the semantic-check-stateful-udf-bag-access branch from 8768204 to 436a5da Compare October 23, 2015 16:22
@ggevay ggevay force-pushed the semantic-check-stateful-udf-bag-access branch from 436a5da to 26e3157 Compare October 23, 2015 16:25
@ggevay
Copy link
Contributor Author

ggevay commented Oct 23, 2015

Thanks, I have addressed all the above comments, and rebased to the current master. I will merge this shortly.

@ggevay ggevay merged commit 26e3157 into emmalanguage:master Oct 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants