Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't parameter names start with a number?

Tags:

powershell

Variable names can be numeric-alpha, why can't parameter names behave this way as well?

Switch parameter starting with a number

like image 232
Rex Hardin Avatar asked Dec 01 '25 08:12

Rex Hardin


1 Answers

Because the first-parameter-char of the command-parameter syntax as specified in the Powershell Language Specification does not allow for it.

2.3.4 Parameters
Syntax:

    command-parameter:
        dash   first-parameter-char   parameter-chars   colonopt

    first-parameter-char:
        A Unicode character of classes Lu, Ll, Lt, Lm, or Lo
        _   (The underscore character U+005F)
        ?

You can find a list of unicode character classes here.

like image 81
Anthony Neace Avatar answered Dec 03 '25 19:12

Anthony Neace



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!