[swift-evolution] [Review] SE-0117: Default classes to be non-subclassable publicly

Károly Lőrentey karoly at lorentey.hu
Sat Jul 9 18:48:22 CDT 2016


On 2016-07-09 22:01:38 +0000, Károly Lőrentey via swift-evolution said:

>> 
>> On 2016. Jul 9., at 22:55, Goffredo Marocchi <panajev at gmail.com> wrote:
>> 
>> Why have they not "fixed" this issue with Java 6/7/8 if it is bad to 
>> have the current setup by default? Why C++ x09/x11/x14 is also not 
>> making everything sealed/unsubclassable by default?
> 
> I'd wager a guess that the strong desire not to break source 
> compatibility with existing code explains why Java and C++ are stuck 
> forever with suboptimal defaults. Some members of this list have a bit 
> of background in C++ language design (understatement of the day!); 
> perhaps they know more.

Quick P.S.: I just remembered that JetBrains' Kotlin exists, and it 
made final classes the default:

"By default, all classes in Kotlin are final, which corresponds to 
Effective Java, Item 17: ‘Design and document for inheritance or else 
prohibit it’."
	-- https://kotlinlang.org/docs/reference/classes.html#inheritance

They even quote the same authority as I did! <3

It seems to have worked out fine in practice, except for some bad 
interactions with some standard Java packages -- which I do not expect 
to be an issue in our case.

-- 
Károly
@lorentey




More information about the swift-evolution mailing list