Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Conversation

@bamarsha
Copy link
Contributor

@bamarsha bamarsha commented Jan 25, 2021

Updates access modifiers to be Internal | Public instead of DefaultAccess | Internal. In the unresolved syntax tree, a default access modifier is QsNullable.Null instead of DefaultAccess. In the resolved syntax tree, it's set to Public, which is the default. This way, AST transformations don't need to know what the default access is, and access modifiers can be compared using standard comparison operators like < or Min.

Requires microsoft/qsharp-runtime#481. Closes #667.

@cesarzc
Copy link
Contributor

cesarzc commented Feb 2, 2021

I am a bit hesitant on the rename from AccessModifier to Visibility. C# refers to them as access modifiers, F# as access control and other languages like C++ also use the term access modifiers so I think it makes sense to use the same term that other languages use.

Even though this is the compiler implementation and not documentation, I think it would be easier for both contributors and users of the compiler public APIs if we used a more familiar term.

I am not completely opposed to the rename but I would like to know what other people think. @ScottCarda-MS, @swernli, @bettinaheim do you have an opinion about renaming AccessModifier to Visibility?

@ScottCarda-MS
Copy link
Contributor

I am a bit hesitant on the rename from AccessModifier to Visibility. C# refers to them as access modifiers, F# as access control and other languages like C++ also use the term access modifiers so I think it makes sense to use the same term that other languages use.

Even though this is the compiler implementation and not documentation, I think it would be easier for both contributors and users of the compiler public APIs if we used a more familiar term.

I am not completely opposed to the rename but I would like to know what other people think. @ScottCarda-MS, @swernli, @bettinaheim do you have an opinion about renaming AccessModifier to Visibility?

I agree with the sentiment @cesarzc made. It is better to use terms that are already out there and familiar to programmers. Additionally, changing the name is a breaking change that I don't think is particularly necessary here, although the behavior of the modifiers is changing in a breaking change anyway. Not changing the name would also make for a much smaller PR with much less code changes, which is always appreciated :) .

@bamarsha
Copy link
Contributor Author

bamarsha commented Feb 2, 2021

changing the name is a breaking change that I don't think is particularly necessary here

It's not strictly necessary, but (1) the removal of DefaultAccess and addition of Public, and (2) the removal of the Modifiers type are already breaking changes to the access modifier API, so the renaming is pretty minor comparatively.

I could call it Access instead. I just think AccessModifier is a particularly long and cumbersome name, even though I named it originally. :)

@swernli
Copy link
Contributor

swernli commented Feb 2, 2021

I don't have strong feelings about changing the name vs not, but I think that the name Visibility might be relying too much on colloquial terminology. I usually talk about a class' visibility but from the C# docs it seems they use the term "accessibility" which makes sense given that the accessibility is modified by the Access Modifiers (https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/access-modifiers). That said, "accessibility" as a noun always makes me think of designing products for use by the differently abled (https://en.wikipedia.org/wiki/Accessibility), so that brings me right back to AccessModifier as both accurate and descriptive without being confused with other concepts.

@cesarzc
Copy link
Contributor

cesarzc commented Feb 2, 2021

I like Sarah's suggestion of calling it Access. It is shorter than AccessModifiers and uses a term that people are already familiar with.

@bamarsha
Copy link
Contributor Author

bamarsha commented Feb 3, 2021

Renamed Visibility to Access.

Copy link
Contributor

@cesarzc cesarzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@bamarsha bamarsha added the needs API review An API review is required label Feb 9, 2021
@bamarsha bamarsha requested a review from bettinaheim February 11, 2021 02:41
@bamarsha bamarsha removed the needs API review An API review is required label Feb 12, 2021
@bamarsha bamarsha merged commit 1fd018a into main Feb 13, 2021
@bamarsha bamarsha deleted the samarsha/public branch February 13, 2021 00:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Access modifiers are not resolved in the syntax tree

6 participants