GithubHelp home page GithubHelp logo

Comments (5)

KirkMunro avatar KirkMunro commented on June 15, 2024 1

Issue for comments to: https://github.com/PowerShell/PowerShell-RFC/blob/master/1-Draft/RFC0011-Dot-Referencing-With-Static-Integers.md.

from powershell-rfc.

lzybkr avatar lzybkr commented on June 15, 2024

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.

KirkMunro avatar KirkMunro commented on June 15, 2024

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.

KirkMunro avatar KirkMunro commented on June 15, 2024

@lzybkr: This is past the 30 day mark. What's next? Discuss internally?

from powershell-rfc.

SteveL-MSFT avatar SteveL-MSFT commented on June 15, 2024

@PowerShell/powershell-committee to discuss

from powershell-rfc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.