Skip to content

Comment on Swift: Not quite there, but too far gone too

Comments

I agree that instances being pass-by-reference is weird, with everything else having copy semantics. It seems as yet another odd artifact of the design constraint that Swift must be ObjC-runtime compatible.

I sort of wish they had created a special type annotation to support legacy ObjC classes, and gone for Go-style structs for the non-legacy OO.

It's more than that. I don't think having non-reference objects is entirely impossible (e.g. Objective-C blocks are already stack-based objects until they are copied), but it doesn't work for Swift's design goals. Objects have to be reference types because Swift needs to interact with Cocoa and Cocoa Touch, which assume reference-sharing in many places.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.