Hacker News new | ask | show | jobs
by lobster_johnson 4399 days ago
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.

1 comments

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.