Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-11188] New abstract keyword for classes #53585

Open
swift-ci opened this issue Jul 23, 2019 · 2 comments
Open

[SR-11188] New abstract keyword for classes #53585

swift-ci opened this issue Jul 23, 2019 · 2 comments
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-11188
Radar None
Original Reporter ColinRoache (JIRA User)
Type New Feature
Additional Detail from JIRA
Votes 0
Component/s
Labels New Feature, LanguageFeatureRequest
Assignee None
Priority Medium

md5: 3568221af408b2c86b03354637ddf549

Issue Description:

I have found numerous instances in which I would like to provide partial protocol conformance in a superclass, while leaving some of the protocol requirements unfulfilled. Traditionally this is called a partially abstract class. While Swift's protocols act as traditional purely abstract classes/structs, it would be helpful to have partially abstract classes/structs which leave some requirements for descendants to fulfill.

I would expect that abstract classes and abstract structs could not be directly initialized and that the init methods could only be called from subclasses' init methods.

I would like to use an abstract keyword like this:

internal
protocol
Plant
{
    
    var plant_genus   : String
    { get }
    var plant_species : String
    { get }
    
}

internal
abstract
struct
Astragalus
: Plant
{
    
    internal var plant_genus : String
    { return "Astragalus" }
    
}

internal
strict
AstragalusAlpinus
: Astragalus
{
    
     internal var plant_species : String
     { return "Astragalus alpinus" }
     
}
@belkadan
Copy link
Contributor

This change would have to go through the Swift Evolution Process. Note that it's come up several times before, so I recommend familiarizing yourself with previous discussions on the forums before writing a pitch.

@swift-ci
Copy link
Collaborator Author

Comment by Colin Roache (JIRA)

@belkadan I have enough of my own code to write, I'm just pointing out the issues remaining in Swift from a type theory perspective.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal compiler The Swift compiler in itself and removed swift evolution approved Flag → feature: A feature that was approved through the Swift evolution process new feature labels Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler The Swift compiler in itself feature A feature request or implementation swift evolution proposal needed Flag → feature: A feature that warrants a Swift evolution proposal
Projects
None yet
Development

No branches or pull requests

3 participants