This is a primarily a design rationale question:
The issue is that the rules are hard to remember, and perhaps knowing why they are the way they are helps with that.
If these work:
$a = 4
Write-Output $a/H # -> '4/H'
Write-Output H/$a # -> 'H/4'
Write-Output H/$(2 + 2) # -> 'H/4'
why shouldn't Write-Output $(2 + 2)/H expand to '4/H' too, instead of being treated as 2 arguments, 4 and '/H'?
Why is a subexpression at the start treated differently than a variable reference?
Also, why is Write-Output .$HOME treated as 2 arguments (only happens if the . is directly followed by a $)?
For a full discussion, please see this Stack Overflow question.
This is a primarily a design rationale question:
The issue is that the rules are hard to remember, and perhaps knowing why they are the way they are helps with that.
If these work:
why shouldn't
Write-Output $(2 + 2)/Hexpand to'4/H'too, instead of being treated as 2 arguments,4and'/H'?Why is a subexpression at the start treated differently than a variable reference?
Also, why is
Write-Output .$HOMEtreated as 2 arguments (only happens if the.is directly followed by a$)?For a full discussion, please see this Stack Overflow question.