-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add SingleValueExpression to type ValueExpressions that always return a single value #283
Conversation
…f Def to SingleValueExpression, along with all dependencies.
…h all dependencies.
…and Self to SingleValueExpression.
…ons to SingleValueExpression.
Codecov Report
@@ Coverage Diff @@
## value-interface #283 +/- ##
================================================
Coverage 100% 100%
- Complexity 1043 1046 +3
================================================
Files 93 94 +1
Lines 1406 1399 -7
Branches 154 150 -4
================================================
- Hits 1406 1399 -7
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
The only thing that looks like something that could be improved is that we now need to add last()
around a few expressions.
Another thing is that last()
will not throw an exception, where the old ValueExpression
s would explicitly check for lists of length 1, and throw an exception in the other cases.
This PR merges to the branch of #282. So please review that first.
Introduces
SingleValueExpression
as proposed in #70.Instead of the
ImmutableList<Value>
that is returned byValueExpression.eval(...)
,SingleValueExpression
has aevalSingle(...)
method with the same arguments that returns anOptional<Value>
.SingleValueExpression
extendsValueExpression
, so that it can be used wherever aValueExpression
is required.The default implementation of the
eval(...)
method onSingleValueExpression
converts an empty result ofevalSingle(...)
to an empty list, otherwise the returned value is stored as single value in the returned list.Converted to
SingleValueExpression
are:Token
arguments:size
argument ofDef
size
argument ofNod
(essentially just a proxy forDef
)n
argument ofRepN
ValueExpression
implementations:CurrentOffset
CurrentIteration
Const
First
Last
Count
Self
ValueExpression
arguments:count
argument ofExpand
initial
argument ofFold
Tasks:
Fold
implementations themselves should also be converted, not just (some of) the argument(s).The unaddressed tasks that was in the list concerning refactoring the type of
Fold
'sreducer
argument now has its own issue: #284.This PR resolves #70.