Comments (5)
Issue for comments to: https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0011-Dot-Referencing-With-Static-Integers.md.
from powershell-rfc.
Two comments:
First, the RFC doesn't mention the most likely break - running a native command like 42.exe
.
Today, if you have a native command that is a decimal number, it can't be invoked with just the number, so using the extension is a natural solution (probably more natural than & 42
.
Second, we need to be sure not to break parsing command arguments, e.g.
echo 1. # Note, no property name
I can easily see this in real world code and parsing as an expression, we'd report a parse error. And no property name shouldn't be a special case, echo 4.thing
should print 4.thing
, not the empty string (assuming no property thing
exists.
from powershell-rfc.
Thanks for the comments @lzybkr.
At the end of the Specification section, the single con that is listed is about that break. I didn't specifically call out invocation of a .exe whose name is an integer though.
On your second point, in the referenced implementation for this (which is linked at the bottom of the RFC), I get the results you expect, which actually both surprises and disappoints me a little. The parser doesn't seem to resolve properties or methods on numeric literals when parsing command parameters in PS5 or PS6. String literals, yes, but numeric literals, no. For example in both versions, echo 'abc'.GetHashCode()
shows me the hashcode for that string, but echo 2l.GetHashCode()
returns a parser error. On the plus side for what you mentioned above, how it works for parameters today doesn't change. On the downside, it means to dot reference any member (property or method) on a numeric literal in a command invocation, you need brackets surrounding the entire thing. At least that would be consistent regardless of the format of numeric literal you use though if this RFC gets approved.
Here is some output from my PS Core dev environment with the parser changes I implemented to try this RFC out:
PS C:\> $PSVersionTable.PSVersion
Major Minor Patch Label
----- ----- ----- -----
6 0 0 alpha
PS C:\> Update-TypeData -TypeName int -MemberType ScriptProperty -MemberName Hours -Value {New-TimeSpan -Hours $this}
PS C:\> 2.Hours.ToString()
02:00:00
PS C:\> echo 2.Hours
2.Hours
PS C:\> echo 1.
1.
PS C:\> echo 4.Thing
4.Thing
from powershell-rfc.
@lzybkr: This is past the 30 day mark. What's next? Discuss internally?
from powershell-rfc.
@PowerShell/powershell-committee to discuss
from powershell-rfc.
Related Issues (20)
- July 15th 2021 Community Call HOT 2
- Create WG labels within RFC repo HOT 1
- Community Call Aug 19, 2021 HOT 1
- September 16th 2021 Community Call HOT 11
- October 21st 2021 Community Call HOT 4
- Nov 18th, 2021 Community Call HOT 21
- Jan 20th, 2022 Community Call HOT 10
- February 17, 2022 Community Call HOT 5
- March 17, 2022 Community Call HOT 3
- April 21, 2022 Community Call HOT 2
- May 19, 2022 Community Call HOT 3
- June 16, 2022 Community Call HOT 3
- July 21, 2022 Community Call HOT 18
- Idea: Release the SecretManagement and SecretStore modules with PowerShell HOT 28
- August 18, 2022 Community Call HOT 1
- September 15, 2022 Community Call HOT 14
- Idea: Is there a need for having ExecutionPolicy for PS7 and WinPS be mirrored?
- October 20th, 2022 Community Call HOT 2
- November 17th Community Call HOT 6
- January 19th Community Call HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from powershell-rfc.