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
KeepOpenThe bot will ignore these and not auto-closeUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semantics
The creation and emission of new types seem pretty straightforward, but I'd need some help with the parsing bits, adding new keywords and expression trees
Mathias R. Jessen (@IISResetMe) I saw your lightning demo and went to your repo afterward. Really amazing work. Your interface DSL actually inspired me, both in how rich it was and since it means interfaces could be made definable in PowerShell without necessarily adding them as a universal language feature. With that said, more complicated things like inheritance might not be so straightforward and would probably need to be part of the parser.
There's a discussion of some of the class-specific stuff in #6418 as well.
But for settling on the syntax and general design, the best place to start might be with an RFC, just to drive discussion on how interfaces should look and what features should be supported in PowerShell. Especially so that the PowerShell Committee can consider it.
Rob Holt (@rjmholt) Thank you for the kind words. I'll try to add support for inheritance to Legislator over the next week, but based on the MSIL generated by CSC for multiple inherited interfaces it looks quite trivial to add.
If we go for something like what sergei (@vors) suggest here, interfaces (including inheritance) would require just a subset of the existing grammar already in place for classes, the only thing missing is basically the interface keyword itself 😃
I'll try to write up an RFC in the coming weeks and submit it to the RFC repo!
I still need to add a type compilation step for interfaces in TypeOps, already have a basic routine working just need to merge it into that branch, will try and add it during this week
Reacted by Flavien MICHALECZEK and Rain Sallow (/u/ta11ow)
Reacted by Steve Lee and Rain Sallow (/u/ta11ow)
Reacted by Flavien MICHALECZEK and Rain Sallow (/u/ta11ow)
Parser rules for interface members are still slightly buggy (; not recognized as statement terminator atm), but it at least produces correct interface types as can bee seen below 😄
Syntax in this implementation also doesn't support get/set control, but it's arguably of limited value unless we decide on whether class properties in PowerShell should behave like fields or actualy properties (at which point we need to generate getters and setters implicitly)
To be clear, Dongbo Wang (@daxian-dbw) and Rob Holt (@rjmholt) can review the implementation, but they don't currently have the time to take it and run it towards a production implementation. Are you still interested in taking it all the way to the finish line if that's the case?
# Actions #
interface Swims {
[bool] Swim();
}
interface Lands {
[bool] Land( $land_spot );
}
interface Flies : Lands {
[bool] Fly( $destination );
}
# Animals #
class Duck : Flies, Swims {
Duck(){}
[bool] Fly( $destination, $land_spot ){
$this.Fly($destination);
$this.Land($land_spot)
return $true
}
[bool] Fly( $destination ){
write-host "The duck flies to $($destination)"
return $true
}
[bool] Land( $land_spot ){
write-host "The duck lands at $($land_spot)"
return $true
}
[bool] Swim(){
write-host "The duck paddles it's flippers idly"
return $true
}
}
class Dove : Flies {
[bool] Fly( $destination, $land_spot ){
$this.Fly($destination);
$this.Land($land_spot)
return $true
}
[bool] Fly( $destination ){
write-host "The dove flies to $($destination)"
return $true
}
[bool] Land( $land_spot ){
write-host "The dove lands at $($land_spot)"
return $true
}
}
# Declarations #
$duck = [Duck]::New()
$dove = [Dove]::New()
function Fly-To([Flies]$flier, $destination){ return $flier.Fly($destination) }
function Swim-Idle([Swims]$swimmer){ return $swimmer.Swim() }
# Tests #
## Should Work ##
Fly-To $duck "Minnesota"
Fly-To $dove "New York"
Swim-Idle $duck
## Should Fail ##
# should error because $dove doesn't implement [Swims]
# or if Duck Typing then because it doesn't implement $_.Swim()
Swim-Idle $dove
The net result being that I don't have to create different versions of Fly-To for Duck and Dove, but Swim-To gives a meaningful error when trying to make the Dove swim
I take it these aren't currently implemented (I can't find documentation for this anywhere) so I was going to submit a feature request but I think this ticket is a match for this pattern? But let me know if it should be a separate issue
Yeah, this more or less would allow for that pattern in full.
From discussions with Mathias R. Jessen (@IISResetMe) as far as I recall, he had the features more or less ready to go, but there were some design decisions he felt shouldn't be made alone and he was trying to solicit feedback on his implementation as Joey Aiello (@joeyaiello) mentioned above.
I don't think that's gone anywhere thus far, though, as far as I can recall the implementation hasn't really had a good look that I'm aware of.
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
KeepOpenThe bot will ignore these and not auto-closeUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Languageparser, language semantics
Activity
GeeLaw commentedon Sep 11, 2016
Also, explicit implementation.
forensicsguy20012004 commentedon Oct 5, 2016
I agree, this would be a great addition to powershell
[-]Interface declaration[/-][+]Interface declaration in classes[/+][-]Interface declaration in classes[/-][+]Support interface declaration using classes[/+]IISResetMe commentedon Apr 10, 2018
I'd love to work on an implementation of this (I already have a ref implementation in PowerShell: https://github.com/IISResetMe/Legislator).
The creation and emission of new types seem pretty straightforward, but I'd need some help with the parsing bits, adding new keywords and expression trees
SteveL-MSFT commentedon Apr 13, 2018
Dongbo Wang (@daxian-dbw) can help you out, but he's going to be attending PSConf.EU next week
cc Rob Holt (@rjmholt)
rjmholt commentedon Apr 13, 2018
Mathias R. Jessen (@IISResetMe) I saw your lightning demo and went to your repo afterward. Really amazing work. Your interface DSL actually inspired me, both in how rich it was and since it means interfaces could be made definable in PowerShell without necessarily adding them as a universal language feature. With that said, more complicated things like inheritance might not be so straightforward and would probably need to be part of the parser.
There's a discussion of some of the class-specific stuff in #6418 as well.
But for settling on the syntax and general design, the best place to start might be with an RFC, just to drive discussion on how interfaces should look and what features should be supported in PowerShell. Especially so that the PowerShell Committee can consider it.
IISResetMe commentedon Apr 13, 2018
Steve Lee (@SteveL-MSFT) Cool, I'll be at PSConfEU as well, will try to catch up with Dongbo Wang (@daxian-dbw)!
Rob Holt (@rjmholt) Thank you for the kind words. I'll try to add support for inheritance to Legislator over the next week, but based on the MSIL generated by CSC for multiple inherited interfaces it looks quite trivial to add.
If we go for something like what sergei (@vors) suggest here, interfaces (including inheritance) would require just a subset of the existing grammar already in place for classes, the only thing missing is basically the
interfacekeyword itself 😃I'll try to write up an RFC in the coming weeks and submit it to the RFC repo!
IISResetMe commentedon Nov 13, 2018
Thanks to a few pointers from Dongbo Wang (@daxian-dbw) last month I got unstuck again 🎉
If anyone wants to check out a working implementation of parser support for
interfacedeclarations, I've pushed it here: https://github.com/IISResetMe/PowerShell/tree/feature/interfacesI still need to add a type compilation step for interfaces in
TypeOps, already have a basic routine working just need to merge it into that branch, will try and add it during this weekIISResetMe commentedon Nov 16, 2018
Here we go: IISResetMe@156e010
Parser rules for interface members are still slightly buggy (
;not recognized as statement terminator atm), but it at least produces correct interface types as can bee seen below 😄Syntax in this implementation also doesn't support get/set control, but it's arguably of limited value unless we decide on whether class properties in PowerShell should behave like fields or actualy properties (at which point we need to generate getters and setters implicitly)
5 remaining items
joeyaiello commentedon Mar 10, 2020
To be clear, Dongbo Wang (@daxian-dbw) and Rob Holt (@rjmholt) can review the implementation, but they don't currently have the time to take it and run it towards a production implementation. Are you still interested in taking it all the way to the finish line if that's the case?
vexx32 commentedon Mar 10, 2020
If necessary, I can pick up the remainder of the necessary work once y'all are done reviewing what's currently done.
I will probably need you to brief me on what's still left in the to-do pile, though, Mathias R. Jessen (@IISResetMe) 😁
Xpyder commentedon Jan 21, 2021
I think this is the right place for this but not 100% sure so if it's not please point me in the right place to post
I'm trying to figure out how to implement Composition Over Inheritance in my powershell scripts.
I think it would go like this:
Diagram for clarity:
The net result being that I don't have to create different versions of Fly-To for Duck and Dove, but Swim-To gives a meaningful error when trying to make the Dove swim
I take it these aren't currently implemented (I can't find documentation for this anywhere) so I was going to submit a feature request but I think this ticket is a match for this pattern? But let me know if it should be a separate issue
vexx32 commentedon Jan 21, 2021
Yeah, this more or less would allow for that pattern in full.
From discussions with Mathias R. Jessen (@IISResetMe) as far as I recall, he had the features more or less ready to go, but there were some design decisions he felt shouldn't be made alone and he was trying to solicit feedback on his implementation as Joey Aiello (@joeyaiello) mentioned above.
I don't think that's gone anywhere thus far, though, as far as I can recall the implementation hasn't really had a good look that I'm aware of.
Strada-EricFr commentedon Jan 3, 2023
No update on the capability to support : interface ?
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.