You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Would currently returns the result of b and scriptblock. That may be desirable and changing the behavior would break the old behavior. This will probably not be doable with functions, but perhaps a new language keyword to distinguish DSL elements.
something like
functiona
{
b
{
write-host'hello'
}
}
DSLfunction b
{
param([scriptblock]$sb)
&$sb
}
This is the reason I highly recommend OTBS or Stroustrup indentation in PowerShell. There are far fewer places you can use Allman and friends.
PowerShell v6.0.0-rc.2
Copyright (c) Microsoft Corporation. All rights reserved.
https://aka.ms/pscore6-docs
Type 'help' to get help.
PS C:\Users\My\Desktop> & 'C:\Users\My\Desktop\TEST.PS1'
The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command n
ame, a script block, or a CommandInfo object.
At C:\Users\My\Desktop\TEST.PS1:25 char:6
+ & $Value
+ ~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : BadExpression
write-host 'hello'
functionb
{
param (
[Management.Automation.Language.DynamicKeyword] $KeywordData,$Name,
[ScriptBlock] $Value,$SourceMetaData,$InstanceName
)
&$Value
}
functiona
{
b
{
write-host'hello'
}
}
a
then run & .\Test.ps1
When I was tasting this out I was doing it with the interactive console on VS Code and executing a block at a time. It appears to not work when used in the same execution block, but if you can separate it out it works. i dunno. I didn't even know this existed until Jason Shirk (@lzybkr)'s comment in this issue.
Yes, the parser has rules in it for DynamicKeywords that let you do things like hang the braces, and #3169 extends that so you can nest keyword contexts, but there are still issues with making the keyword functionality robust and predictable enough and they require some work to solve.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Activity
markekraus commentedon Feb 20, 2018
I can't see how this could ever be added.
b { write-host 'hello' }Would currently returns the result of
bandscriptblock. That may be desirable and changing the behavior would break the old behavior. This will probably not be doable with functions, but perhaps a new language keyword to distinguish DSL elements.something like
This is the reason I highly recommend OTBS or Stroustrup indentation in PowerShell. There are far fewer places you can use Allman and friends.
lzybkr commentedon Feb 20, 2018
Dynamic keywords enable this scenario (first introduced with DSC).
This #3169 was an attempt at properly supporting DSLs in PowerShell.
markekraus commentedon Feb 20, 2018
Jason Shirk (@lzybkr) awesome!
p0W3RH311
here is how you could make that work now:
p0W3RH311 commentedon Feb 22, 2018
Mark Kraus (@markekraus)
markekraus commentedon Feb 22, 2018
Heh.. that's weird. works if I do this:
Test.ps1:
Test2.ps1:
then run
& .\Test.ps1When I was tasting this out I was doing it with the interactive console on VS Code and executing a block at a time. It appears to not work when used in the same execution block, but if you can separate it out it works. i dunno. I didn't even know this existed until Jason Shirk (@lzybkr)'s comment in this issue.
lzybkr commentedon Feb 22, 2018
There's a reason it's not formally supported yet.
rjmholt commentedon Feb 23, 2018
Yes, the parser has rules in it for
DynamicKeywords that let you do things like hang the braces, and #3169 extends that so you can nest keyword contexts, but there are still issues with making the keyword functionality robust and predictable enough and they require some work to solve.microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.