You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add use static <class> usage to allow static member access in PowerShell #5099
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeWG-Languageparser, language semantics
Today, method invocation uses an operator with an expression before the method name (e.g. $o. or [t]:: ), otherwise the parser sees a command invocation.
The parentheses do not help disambiguate, and there are other quirks to note:
The strict mode error only happens if there is no space, as folks learning PowerShell were invoking functions like methods, but surprised that arguments weren't passed as expected. If there is a single argument, the parens don't matter, but if there are multiple arguments, the parens group the values in the first argument.
Some possible solutions for the ambiguity:
Call static methods like functions:
using static Math
using static Console
pow 12
pow -y 2-x 1# Same as previous line, named args
WriteLine "hello"
Continue to use :: (a breaking change, but probably safe):
using static Math
::pow(1,2)
Extra work at parse time (before semantic checks) so method/property names are not parsed like commands.
personally, I like the idea of them becoming function-esque. But if property members are also exposed, that might look weird.
using static System.Globalization.CultureInfo
CurrentCulture = CreateSpecificCulture "nl-NL"
That looks odd.
I like the :: prefix/sigil idea. Makes it a little less confusing. i was thinking a sigil would be nice, and there already kind of is one for this usage.
Reacted by Keith Hill, dzmitry-lahoda and Mikey Lombardi (He/Him)
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Issue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifIssue-Enhancementthe issue is more of a feature request than a bugKeepOpenThe bot will ignore these and not auto-closeWG-Languageparser, language semantics
Activity
lzybkr commentedon Oct 12, 2017
The proposed syntax is ambiguous with commands.
Today, method invocation uses an operator with an expression before the method name (e.g.
$o.or[t]::), otherwise the parser sees a command invocation.The parentheses do not help disambiguate, and there are other quirks to note:
The strict mode error only happens if there is no space, as folks learning PowerShell were invoking functions like methods, but surprised that arguments weren't passed as expected. If there is a single argument, the parens don't matter, but if there are multiple arguments, the parens group the values in the first argument.
Some possible solutions for the ambiguity:
::(a breaking change, but probably safe):markekraus commentedon Oct 12, 2017
personally, I like the idea of them becoming function-esque. But if property members are also exposed, that might look weird.
That looks odd.
I like the
::prefix/sigil idea. Makes it a little less confusing. i was thinking a sigil would be nice, and there already kind of is one for this usage.microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.