You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have already talk about what metadata is, and all it uses. One problem that I still see is that though we now have a way to apply metadata without the need of doing as with a type, using the new <~ operator. We still don't have nice way to type checkit.
For example in order of CData to be applied we have to set the metadata {cdata: true}, and here we have two problems one that users need to remember the name of the keys and its value type, and second that if you did some miss spelling like {cData: true} it doesn't work, and you don't get any error or hint why not.
Solutions
Use functions to apply metadata
One option would be let's create functions that allows us to apply metadata with typed values. For example this would be
%dw 2.0
output application/xml
fun cdata<T>(a: T, cdata: Boolean) : T = do {
a <~ {cdata: cdata}
}
---
root: "DW Rocks" cdata true
Pros
Doesn't require anything new from the language
Fixes both issues as it will validate the argument and the tooling will validate the parameters
Drawback Open Questions
How is this going to work with type definitions
Is function call the proper tool to apply metadata that is something that is not really changing the value?. Does it contaminate the script?
Should we start investigating to handle types as values so we can apply functions to the types to attach metadata.
Typed Metadata
Pre-read: #40 .
We have already talk about what metadata is, and all it uses. One problem that I still see is that though we now have a way to apply metadata without the need of doing
as
with a type, using the new<~
operator. We still don't have nice way to type checkit.For example in order of CData to be applied we have to set the metadata
{cdata: true}
, and here we have two problems one that users need to remember the name of the keys and its value type, and second that if you did some miss spelling like{cData: true}
it doesn't work, and you don't get any error or hint why not.Solutions
Use functions to apply metadata
One option would be let's create functions that allows us to apply metadata with typed values. For example this would be
Pros
Drawback Open Questions
Use annotations
Use annotation to attach metadata
With this approach we can let the engine that all the fields of the
Annotation
should be attached to the value as metadata values.We can take this approach and take it to type expressions
Pros
Cons
The text was updated successfully, but these errors were encountered: