stevedlawrence commented on a change in pull request #218: Implement 
dfdl:choiceLength='explicit'
URL: https://github.com/apache/incubator-daffodil/pull/218#discussion_r291310406
 
 

 ##########
 File path: 
daffodil-core/src/main/scala/org/apache/daffodil/grammar/primitives/ChoiceCombinator.scala
 ##########
 @@ -67,9 +68,19 @@ case class ChoiceCombinator(ch: ChoiceTermBase, 
alternatives: Seq[Gram])
 
   lazy val optChoiceDispatchKeyKind = Some(ch.choiceDispatchKeyKind)
 
+  // dfdl:choiceLength is always specified in bytes
+  private lazy val choiceLengthInBits: Long = ch.choiceLengthKind match {
+    case ChoiceLengthKind.Explicit => ch.choiceLength * 8
+    case ChoiceLengthKind.Implicit => 0 // When using 
choiceLengthKind='implicit', this value will simply be ignored
 
 Review comment:
   What if we change the type of  ``choiceLengthInBits`` to a  ``Maybe[Long]``? 
Then we don't have to ignore the value. Either we have a length and we use it, 
or there's no value to use. Same effect, but the type is a hint that we may or 
may not have a value and we can't accidentally use a 0.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to