-
Notifications
You must be signed in to change notification settings - Fork 114
Style guide discussion: naming convention for entry points #875
Comments
Interesting discussion. I don't have more pros for any of the options, but I do think that when accessibility and consistency with the style guide are confronted we should seek accessibility. Even at the expense of less consistent style rules. In general, many users don't follow strictly the style guides. We want to make the language as accessible as possible to get broader audiences. Familiarity with other languages is always a very strong feature for accessibility. So I'll go for Main(), but don't take my opinion very seriously since I'm just a noob in computer science and programming languages! |
As you pointed out, I'm of the opinion we should use |
And, like in C#, it should be more of a convention than a rule enforced by the compiler. |
So what do we decide? Shall we modify the documentation and the style guide? |
@geduardo: Thanks for the ping, easy for these kinds of discussions to get lost. I definitely appreciate your and @anpaz-msft's perspectives, but I'd also like to get a little bit more input before resolving if possible. |
I agree @cgranade, this is an important discussion. More people should be involved. Tagging some people to raise awareness: |
I would prefer to use descriptive operation names instead of I think that other languages originally used Even in languages where the name IMO, a good Q# entry point should be indistinguishable from other operations, and the name should reflect that. I don't know if Q# should support multiple entry points, but I do think that we should try to make it clear that changing where your Q# program starts is as easy as moving the |
I would absolutely agree with @samarsha. I don't think the familiarity to other languages will have much particular benefit, because I can't imagine "add Additionally, I think the confusion of when to rename each entry point operation would go well beyond a few additions to the style guide. Considering that interop allows calling multiple Q# operations from the host program, would the
Further, thinking about the potential path of Q# users and less about the simplicity of the docs, consider someone who has gotten familiar with Q# via the standalone executable, but now would like to start using a host program to export/plot their results. Instead of "remove the In a nutshell: I'm of the opinion that the benefits of changing to |
Re @anpaz-msft:
I think that can often be the case, but we have seen examples such as recursive entry points for the postselected-qrng that speak to the "entry points as ordinary operations" view as well. I would suspect that would become more common if multiple entry points are allowed.
Thanks for your input, and for starting this discussion! Re @geduardo (emphasis mine):
This is a good point, but I honestly think this pushes more towards entry points as ordinary operations; if we think people won't consistently use the name
I really appreciate your input, @geduardo! Re: @samarsha
This is a really good point; suggesting
Agreed, we don't want Q# users to have to worry with
Tangenting slightly, I do think multiple entry points would be a really good future addition, similar to how CUDA projects can expose multiple executable kernels. A host program may decide during the course of its workflow to dispatch Q# applications with fundamentally different signatures to target machines, such that exposing them through multiple entry points could make a lot of sense. Consider a QML workflow, for instance, with training and classification steps; these would share a lot of internal code such that collecting them in one project makes sense, but they would still be called with fundamentally different input signatures. Having a naming convention in our style guide that allows for this future extensibility seems like a good idea to me. Re: @gillenhaalb
I think this in particular speaks to @samarsha's point that entry points should be ordinary operations, including in terms of the style guide.
|
Re: @samarsha
This is a very good point!
Mmm, while I agree that moving the
Given the purpose of quantum computing (and therefore of Q#), that is mainly to be used to compute hard operations, I think this structure will prevail and the feature of changing the @entrypoint() might not be as used as we expect. But I agree, having the @entrypoint() attribute and also having the convention of naming the main function as |
I'll vote for entry points as ordinary operations and not reiterate the points folks have made above :-) |
Given what seems to be the consensus from the discussion so far, I'm happy to say let's go with the "entry points as ordinary operations" alternative unless either @anpaz-msft or @geduardo has strong opposition. |
With the introduction of Q# standalone executables, we now have an
@EntryPoint()
attribute that can be used to denote that an operation should be the entry point into a Q# application when called at the command line, and that the operation is available for interoperability with .NET and Python. In conventional classical languages, entry points are often called some form of "main" (e.g.:main
,Main
, or__main__
) to expose them and to denote that they are entry points. As per that convention, @anpaz-msft has raised the point that Q# operations marked as@EntryPoint()
should be namedMain()
by convention, even if that would otherwise not be consistent with the style guide. This issue is intended to kick off that discussion and to make sure that wherever we wind up landing on this case, that the style guide gives explicit and actionable guidance about how to name entry points.In that spirit, I've written out my own thoughts; I tend towards naming entry points as ordinary operations, so my list of thoughts is necessarily a bit biased as result, but I can definitely see the argument of naming entry points as
Main()
as well.Main()
:@EntryPoint()
is not familiar.@EntryPoint()
and operation name.The text was updated successfully, but these errors were encountered: