Syntax ideas for supporting extension resources with lexical nesting #1567
-
Syntax ideas for supporting extension resources with lexical nestingThis is an open discussion thread to come up with a syntax for declaring extension resources in a manner compatible with #1363. To get started, here are the options I see: 1. Try to infer ita) Use the fact that the fully-qualified type must be suppliedresource myParent 'My.Rp/parent@2020-01-01' = {
name: ...
// this is an extension resource (type contains a single '/' character)
resource myExtension 'My.OtherRp/extension@2020-01-01' = {
name: ...
}
// this is a child resource (type does not contain any '/' characters)
resource myChild 'child@2020-01-01' = {
name: ...
}
}
b) Use a list of known extension types to understand whether or not the provided type string is an extension resourceNot considered - this removes the 'day 0 resource support' promise. 2. Some indicator of intent in the language or type stringa) Keywordresource myParent 'My.Rp/parent@2020-01-01' = {
name: ...
// 'extension' keyword
resource myExtension 'My.OtherRp/extension@2020-01-01' extension = {
name: ...
}
} b) Prefix in the type stringresource myParent 'My.Rp/parent@2020-01-01' = {
name: ...
// prefix for the type string (option i)
resource myExtension 'ext://My.OtherRp/extension@2020-01-01' = {
name: ...
}
// prefix for the type string (option ii)
resource myExtension '/My.OtherRp/extension@2020-01-01' = {
name: ...
}
// option iii - some other prefix (not shown)
}
Current state of the 'top-level' extension/child syntax (for reference)resource myParent 'My.Rp/parent@2020-01-01' = {
name: ...
}
// Extension resource
// NOTE - the type string for the resource being extended is not present in this declaration
// NOTE - there's also a potential proposal to rename 'scope' => 'extends'
resource myExtension 'My.OtherRp/extension@2020-01-01' = {
name: ...
// declare the resource that this one is extending
scope: myParent
}
// Child resource
// NOTE - the type string is the fully-qualified type string instead of just 'child'. This is to permit intellisense before the 'parent' property has been entered.
resource myChild 'My.Rp/parent/child@2020-01-01' = {
name: ...
// declare the resource that this one is a child of
parent: myParent
} NotesIf picking option 1, it feels like it would make sense to come up with a consistent mapping between the 'top-level' syntax and the 'nested' syntax which combines both the 'parent' & 'scope' property into one. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
Dumb question (I am good at those): it seems like this is functionally different because these two concepts have a different effect on how the resources are emitted....
Basically what I'm probing at, given the current state example - these look really similar (scope vs parent). Are the differences truly cosmetic or semantic? |
Beta Was this translation helpful? Give feedback.
-
I think if we can say with 100% certainty that if the RP namespace is present ( And if the above is true, then we should use a single property name for the parent/scope when declared as a top level resource and use the same logic to distinguish between the two cases. Basically, if there are no computationally ambiguous cases, then let's not add anything. It is a subtle different in how we process the code, but I think functionally user's don't need to care about the difference in semantics. They will know that extensions like DiagnosticSettings or Locks require the RP name. |
Beta Was this translation helpful? Give feedback.
-
I happen to think this is a pro, not a con. Intellisense is going to show me all possible "nested" types that I can include in a resource -- both children and extension. |
Beta Was this translation helpful? Give feedback.
-
When I look at 2b - it really makes me think we're complicating rather than simplifying (or rather we already have the answer)... To me, the cleanest is building off of the parent property (and scope as mentioned above) and then using the correct property for the correct scenario makes it much easier to master. We may not get the intellisense we want but maybe we need to solve that differently than we do today if that's the only thing we're stuck on... so I do think we need to bring this into the conversation:
From a user perspective - I'm not sure what's missing from that... (and now that I type it, not sure what's missing for intellisense/autocomplete either) |
Beta Was this translation helpful? Give feedback.
moved to new issue, will close here.