bsloane1650 opened a new pull request #264: WIP - DAFFODIL-2169
URL: https://github.com/apache/incubator-daffodil/pull/264
 
 
   The groundwork for adding type-safty to our DPath and infoset values.
   
   This doesn't actually effect any of the existing code yet, but should give 
any idea on what I am planning. Given the volume of effort needed to actually 
incorporate this into the codebase, I wanted to get feedback before I attempted 
to do so.
   
   When I do thread it through, I suspect I will run across other issues. I'll 
try to keep the "meaningful" changes separate from the boilerplate updates to 
type signatures.
   
   The bad:
   1) We need to support having DINodes, but also need the DataValue type to be 
visible to Daffodil-lib (because we will want to use it for the 
number-conversion functions). I am accomplishing this by defining a trait it 
DataValue.scala that is instantiated only by DINode, along with an implicit to 
convert back to a DINode. I don't think this will cause additional memory 
allocations, but it might invoke an additional typecheck when we try to get 
extract a DINode.
   2) We still need to thread this through all of Daffodil. 
   
   The good:
   1) DataValue is not AnyRef
   2) By using phantom types, we can impose an arbitrary type hierarchy on our 
DataValue.I suspect the only useful useful distinction here is going to be 
Nullable vs NonNullable.
   We might also be able to take advantage of the seperate DataValue types for 
each supported underlying type. In particular, we might use them to tighten the 
return type when subclassing. In theory, we could have done that when using 
AnyRef, but not that the types are still marked as DataValue it may be clearer 
what is going on.
   I also included DataValuePrimitive to indicate types which are definined in 
Daffodil-lib. This is mostly just a demo that this is possible to define more 
complicated type hierarchies. I don't actually see a way to take advantage of 
it.
   
   

----------------------------------------------------------------
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