[
https://issues.apache.org/jira/browse/THRIFT-3812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15336340#comment-15336340
]
ASF GitHub Bot commented on THRIFT-3812:
----------------------------------------
Github user apocolipse commented on the issue:
https://github.com/apache/thrift/pull/1002
In my opinion this is very Un-Swifty. Namespace prefixes are an
Objective-C Cocoa convention, Swift tries to get away from this convention (in
fact with Swift 3.0, NS prefixes on many Foundation types have been dropped*)
It would be more proper to Nest them instead of rename them, and not that
difficult either, simply install everything in a struct:
```
namespace swift MyNamespace
struct MyStruct { ... }
service MyService { ... }
```
```swift
struct MyNamespace {
struct MyStruct { ... }
protocol MyService { ... }
}
```
Alternatively, Swift uses Module scoping for namespacing, so having the
generator spit out an Xcodeproj with a Framework scheme, or SPM formatted file
hierarchy, would be ideal, this would give you import semantics and direct
access to your types when there's no conflicts,
```swift
import MyNamespace
var aStruct = MyStruct()
```
as well as nested access when conflicts exist
```swift
var aStruct = MyNamespace.MyStruct()
```
Either module scoping or nesting are the ideal Swifty ways to leverage
namespaces, Name prefixing shouldn't be used here.
*Dropped where types have been added as value types for more Swift-like
handling, mutability, etc.
> Option to prefix namespace to Swift type names
> ----------------------------------------------
>
> Key: THRIFT-3812
> URL: https://issues.apache.org/jira/browse/THRIFT-3812
> Project: Thrift
> Issue Type: New Feature
> Components: Swift - Compiler
> Reporter: HÃ¥kon Hitland
> Priority: Minor
>
> Swift does have a way to namespace things within a pod, which can lead to
> name collisions.
> This adds an option "swift:prefix_namespace" that will add Cocoa-style
> prefixes to the generated code if the file has a defined Swift namespace.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)