Feature: types for open trees #420
fmontesi
started this conversation in
Ideas (Features, Fixes, etc.)
Replies: 1 comment 3 replies
-
|
Great! what about giving also the possibility to express a regex? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Our types are roughly equivalent to "closed records": a type does not allow for any subnode that is not specified in the type.
The only way we have to allow for subnodes with unknown names is by using
{ ? }, for example:We could replace this with a more powerful feature: using
?as a placeholder for "unknown names".For example, the following type allows for any subnodes as long as they have type
int:This would allow us to specify some keys for which we want a different type, and then use
?to have an "open record" (or map, or dictionary, if you like) where all the other nodes have some other type, as follows.The old
?primitive would become just syntactic sugar for this new primitive:type T { ? }would be interpreted astype T { ?:undefined }.With this primitive, we could actually write the
undefinedtype in Jolie as the following recursive type:Beta Was this translation helpful? Give feedback.
All reactions