[swift-evolution] [Review] SE-0026 Abstract classes and methods

David Scrève david.screve at dlta-studio.com
Thu Mar 3 15:28:37 CST 2016




> Le 3 mars 2016 à 22:23, Alsey Miller via swift-evolution <swift-evolution at swift.org> a écrit :
> 
> My thoughts exactly! I don’t not understand the following statement:
> 
>> Yes, a protocol will force you to provide an implementation. However, a protocol *by itself* cannot force the implementor of a class to provide an implementation unless that class declares itself in conformance with that protocol.
> 
> My argument is that declaring to be the subclass of an abstract class, or declaring to be in conformance with a protocol would have the same effect. Even the syntax would be the same, e.g. 
> 
> class ConcreteClass: AbstractSuperclass { … }
> 
> or 
> 
> class ConcreteClass: ProtocolWithoutExtensions { … }
> 
> 	Coleman,
> 
Not really the same : The abstract class support encapsulation : In the abstract class, you can have private attributes and privates methods that encapsulate some kind of behavior and only some methods will be made abstract.

Encapsulation cannot be supported by protocols and if you want to add a full encapsulation in protocol, it will result of a kind of class in protocol syntax….

Regards,

David


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160303/ad56211f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4233 bytes
Desc: not available
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160303/ad56211f/attachment.p7s>


More information about the swift-evolution mailing list