-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for operation templates and operation signature reuse #552
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start! A couple things to consider here. We also chatted offline about not introducing a new node type for "operation instance" but instead having operation nodes gain a "signature" node which is either a reference signature (containing a type reference) or a parameters signature (containing a parameter list).
4d14e95
to
92f97e9
Compare
You can try these changes at https://cadlplayground.z22.web.core.windows.net/prs/552/ |
a012633
to
763f481
Compare
Discussed this with @daviwil but I wanted to raise a concern I had here also in case others have ideas - I think the syntax is maybe somewhat reasonable in interfaces, but in operations I find this hard to grok. The issue is that colon sets off the return type, and now it might also set off a reference to another operation. So given code like:
I can see two reasonable reads - an operation which takes no parameters and returns a A couple fixes were discussed, though none jumped out as excellent:
Any thoughts here? |
I think it'd be a lot more disruptive to change operation return type syntax. I'm OK with using the following for non-interface operations:
I think it will be more common for folks to use signature references inside of interfaces where the syntax is smoother. That's what I've been doing today and it looks pretty nice. |
If we make any distinction between namespace and interface operations for this syntax, it will kind of makes me regret allowing I agree changing return type now would be very disruptive, much as I like |
The other style strangeness I see is the casing. We previously said op names should be camelCased, but |
Yeah, the pattern I've been following without really thinking about it is to have reusable signature names be pascal-cased. I didn't follow that in the unit tests I wrote, though.
|
@bterlson How should we proceed here? |
is |
I don't have a strong feeling. I'm OK with |
Here's what it would look like to use
It looks a little "off" to me aesthetically (and "get is ResourceRead ..." sounds weird), but if the consensus is that we should go with |
Or in other words, please let me know if I should make the change and I'll get it done today :) |
952d6ea
to
94c7663
Compare
I went ahead and pushed a commit to this PR with the |
I'm not sure, but I think this change might throw off the tmlanguage coloring, so that's worth double checking. Maybe add a test to packages/cadl-vscode/test. I thought of this as I was thinking coloring to set-off the name from the |
PR here: #576 |
3864d80
to
ebde6be
Compare
Oh lord, what now...
|
Since this is unrelated to this PR, I'll go ahead and merge and then chat with @markcowl and others about how we can resolve the security alert issue correctly (it's referring to NuGet packages). |
Let me know if you want me to make any further tweaks in a future PR!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retroactive looks great, excited to use this (not excited to merge with my PR).
This change fixes #459 by implementing support for both templated operations and the definition of operations that are based on the signature of another operation (no matter how it was defined).
Here's a contrived example (sample output here):
A couple of important things to note:
model is
semantics