TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Access Control in Swift

81 点作者 rjsamson将近 11 年前

8 条评论

comex将近 11 年前
Note that as seems to be in vogue these days (Go, Rust), access to a class's methods and fields is never directly tied to code being "inside" the class; even `private` entities are accessible from anywhere in the same source file. I guess this is a good thing, as it avoids awkwardness with anything implemented as a function rather than a method, and works as a substitute for most cases where "friend" would be acceptable coding style in C++.
评论 #8078371 未加载
评论 #8079781 未加载
评论 #8079158 未加载
austinz将近 11 年前
There's also a blog post preceding this one that talks about call-by-name-esque semantics using "@auto_closure"; it's definitely worth a look.
jackjeff将近 11 年前
Anybody else missing "protected" access? Looking at the semantics of "private" I doubt it's coming...
评论 #8078944 未加载
评论 #8078804 未加载
评论 #8078548 未加载
icodestuff将近 11 年前
It's an interesting choice, but I think I'd have rather had a sensible default for each type category than one (internal) for everything. For instances: public classes, public enums, private or internal ivars, public methods, etc. Just to cut down on the boilerplate.
评论 #8078086 未加载
Dewie将近 11 年前
It seems that they have chosen a default (internal, though I don't know how to interpret how "most of the time" works) which is similar to the default modifier in Java. It seems, though, that java's default modifier was maybe ill-chosen, as private and public modifiers seem far more prevalent than no modifier (which means that the default modifier is used) in java code.
评论 #8077975 未加载
评论 #8079262 未加载
voidlogic将近 11 年前
I think its pretty unfortunate Apple chose the name used by OpenStack's Object Storage (Swift)...
评论 #8079271 未加载
评论 #8078033 未加载
评论 #8078332 未加载
fjcaetano将近 11 年前
Finally! If they implement multiple inheritance I think I'll have a nerdgasm!
评论 #8077983 未加载
评论 #8077944 未加载
keyle将近 11 年前
This language feels very unfinished... I've seen 0.8 languages being far more polished. Maybe I'm just biased? Swift looks good though. But it's only as good as the Cocoa framework bindings really.
评论 #8078146 未加载
评论 #8078075 未加载