René's URL Explorer Experiment


Title: Do not require { ... } around variable names for null-conditional member access · Issue #11379 · PowerShell/PowerShell · GitHub

Open Graph Title: Do not require { ... } around variable names for null-conditional member access · Issue #11379 · PowerShell/PowerShell

X Title: Do not require { ... } around variable names for null-conditional member access · Issue #11379 · PowerShell/PowerShell

Description: Follow-up from #3240. Null-conditional member access (?.) was implemented and will be available as an experimental feature in 7.0 However, in the interest of backward compatibility the implementation currently requires that the variable ...

Open Graph Description: Follow-up from #3240. Null-conditional member access (?.) was implemented and will be available as an experimental feature in 7.0 However, in the interest of backward compatibility the implementati...

X Description: Follow-up from #3240. Null-conditional member access (?.) was implemented and will be available as an experimental feature in 7.0 However, in the interest of backward compatibility the implementati...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11379

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Do not require { ... } around variable names for null-conditional member access","articleBody":"Follow-up from #3240.\r\n\r\nNull-conditional member access (`?.`) was implemented and will be available as an _experimental_ feature in 7.0\r\n\r\nHowever, in the interest of backward compatibility **the implementation currently requires that the variable name be enclosed  in `{...}`**, because `?` is technically a legal character in a variable name whose use surprisingly _doesn't_ require `{...}`.\r\n\r\nThat is, if you want to ignore an attempt to call`$obj.Method()` if `$obj` is `$null` (or undefined), you would expect the following, analogous to C#:\r\n\r\n```powershell\r\n# Does NOT work as intended.\r\n# 'obj?' as a whole is interpreted as the variable name.\r\n$obj?.Method()\r\n```\r\n\r\nInstead, you must currently use:\r\n\r\n```powershell\r\n# !! Must enclose 'obj' in {...} to signal that '?' is a syntactic element as part of '?.'\r\n${obj}?.Method()\r\n```\r\n\r\n_Update_: Null-coalescing - `$var??='default` and `$a??$b` - and the ternary operator - `$var?1:0` - are similarly affected (though there the use of whitespace before the `?` resolves the issue).\r\n\r\nThis requirement is (a) unexpected and (b) cumbersome:\r\n\r\n* New users will not expect the need for `{...}` and won't necessarily know that _it_ is what is required when the following fails (possibly _undetected_, unless `Set-StrictMode -Version 2` or higher is in effect): `$o = [pscustomobject] @{ one = 1 }; $o?.one`\r\n\r\n* Even once users _do_ know about the need for `{...}`:\r\n  * They will forget to use it on occasion, because of the counter-intuitive need for it.\r\n  * When they do remember, this seemingly artificial requirement will be an ongoing source of frustration, especially since `{...}` is hard to type.\r\n\r\n**Use of `{...}` shouldn't be necessary, and while not requiring it amounts to a _breaking_ change, it arguably falls into [bucket 3: Unlikely Grey Area](https://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/breaking-change-contract.md#bucket-3-unlikely-grey-area).**\r\n\r\n---\r\n\r\n### Why this change should be considered acceptable:\r\n\r\nNote: @rjmholt discusses why changing PowerShell's syntax is highly problematic _in general_ in [this comment](https://github.com/PowerShell/PowerShell/issues/3240#issuecomment-565745004), but for the reasons presented below I think it is worth making an exception here.\r\n\r\n`?.` is a _new_ syntactic feature; by definition scripts that use it _cannot_ (meaningfully) run on older versions - unless you specifically add conditionals that provide legacy-version-compatible code paths, but that seems hardly worth it - you would then just stick with the legacy features.\r\n\r\nYes, the interpretation of `$var?.foo` in old scripts that used `$var?` as  a variable name would break, but:\r\n\r\n* `?` should never have been allowed as part of an identifier _without enclosing it in `{...}`_.\r\n\r\n* Since being able to do so is unexpected and probably even _unknown_ to many, such variable names are exceedingly rare in the wild, speaking from personal experience, but [@mburszley's analysis provides more tangible evidence](https://github.com/PowerShell/PowerShell/issues/3240#issuecomment-526179551).\r\n\r\n   * Even Ruby only allows `?` (and `!`) at the _end_ of identifiers, and there only of _method_ identifiers, and I suspect that most Ruby users are aware that they should _not_ assume that other languages support the same thing.\r\n\r\nSo, pragmatically speaking:\r\n\r\n* The vast majority of existing code will not be affected - a token such as `$var?.foo` will simply not be encountered.\r\n\r\n* If you write `$var?.foo` with the new semantics, then yes, running that on older versions could result in different behavior (rather than breaking in an obvious manner), depending on what strict mode is in effect - but _you should always enforce the minimum version required to run your code as intended anyway_ (`#requires -Version`, module-manifest keys).\r\n\r\nAll in all, to me this a clear case of a bucket 3 change: a technically breaking change that breaks very little existing code while offering real benefits (or, conversely, avoiding perennial headaches due to unexpected behavior).\r\n\r\n\r\n\r\n\r\n\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-12-17T16:25:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":53},"url":"https://github.com/11379/PowerShell/issues/11379"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:75bc28fd-0a14-cd9b-21f9-e603cbd6f8fc
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC386:22943D:F71EA:15B208:6A5A40A7
html-safe-nonce2d968e82dbddaa2689f6d1ddd48eeada8e9729cd2acc1a9d3ebd92c1e7a10344
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMzg2OjIyOTQzRDpGNzFFQToxNUIyMDg6NkE1QTQwQTciLCJ2aXNpdG9yX2lkIjoiMjQzMjMwMTkwMjA1MjYwNjExOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac820771ddd5e5dd41152dbc1e65b346b911d815c96e66b3f43d9731b3f4d8ffc8
hovercard-subject-tagissue:539174894
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/11379/issue_layout
twitter:imagehttps://opengraph.githubassets.com/a927a238c0586fdc58d8c3500b97c3dcdd06ae13b80af53fa95a2ee6cbd3c3fe/PowerShell/PowerShell/issues/11379
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/a927a238c0586fdc58d8c3500b97c3dcdd06ae13b80af53fa95a2ee6cbd3c3fe/PowerShell/PowerShell/issues/11379
og:image:altFollow-up from #3240. Null-conditional member access (?.) was implemented and will be available as an experimental feature in 7.0 However, in the interest of backward compatibility the implementati...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
None19c67ad7579d2401ff06e88a32ef45460fbb40fab3191c7f7582d5e166f326fc
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasee618485bff22dab2ef1ffb4e34e4e6626688df69
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/11379#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F11379
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F11379
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/11379
Reloadhttps://github.com/PowerShell/PowerShell/issues/11379
Reloadhttps://github.com/PowerShell/PowerShell/issues/11379
Please reload this pagehttps://github.com/PowerShell/PowerShell/issues/11379
PowerShell https://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Notifications https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Fork 8.4k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Star 54.5k https://github.com/login?return_to=%2FPowerShell%2FPowerShell
Code https://github.com/PowerShell/PowerShell
Issues 1.3k https://github.com/PowerShell/PowerShell/issues
Pull requests 287 https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality 3 https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Code https://github.com/PowerShell/PowerShell
Issues https://github.com/PowerShell/PowerShell/issues
Pull requests https://github.com/PowerShell/PowerShell/pulls
Discussions https://github.com/PowerShell/PowerShell/discussions
Actions https://github.com/PowerShell/PowerShell/actions
Projects https://github.com/PowerShell/PowerShell/projects
Security and quality https://github.com/PowerShell/PowerShell/security
Insights https://github.com/PowerShell/PowerShell/pulse
Do not require { ... } around variable names for null-conditional member accesshttps://github.com/PowerShell/PowerShell/issues/11379#top
Committee-ReviewedPS-Committee has reviewed this and made a decisionhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Committee-Reviewed%22
Issue-Enhancementthe issue is more of a feature request than a bughttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Enhancement%22
WG-Languageparser, language semanticshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Language%22
https://github.com/mklement0
mklement0https://github.com/mklement0
on Dec 17, 2019https://github.com/PowerShell/PowerShell/issues/11379#issue-539174894
#3240https://github.com/PowerShell/PowerShell/issues/3240
bucket 3: Unlikely Grey Areahttps://github.com/PowerShell/PowerShell/blob/master/docs/dev-process/breaking-change-contract.md#bucket-3-unlikely-grey-area
@rjmholthttps://github.com/rjmholt
this commenthttps://github.com/PowerShell/PowerShell/issues/3240#issuecomment-565745004
@mburszley's analysis provides more tangible evidencehttps://github.com/PowerShell/PowerShell/issues/3240#issuecomment-526179551
Committee-ReviewedPS-Committee has reviewed this and made a decisionhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Committee-Reviewed%22
Issue-Enhancementthe issue is more of a feature request than a bughttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Enhancement%22
WG-Languageparser, language semanticshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Language%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.