Github user dcelasun commented on the issue:

    https://github.com/apache/thrift/pull/1156
  
    Hey @Jens-G, I'm not sure I follow you, what does this have anything to do 
with maps? Assuming you meant sets, the docs say:
    
    > An unordered set of unique elements. Translates to an STL set, Java 
HashSet, set in Python, etc. Note: PHP does not support sets, so it is treated 
similar to a List
    
    Similar to PHP, Go does not have a native type for sets, so the best thing 
to do is to treat it similar to a list.
    
    > Given that, I would say it could be one option to error, when the user 
inserts a duplicate.
    
    This is not possible, because the caller doesn't "insert" anything, they 
simply return a slice. Consider the following:
    
    ```thrift
    service Foo {
        set<string> bar() throws (1: Something error)
    }
    ```
    
    This generates an interface called `Foo` with the following method:
    
    ```go
    type Foo interface {
        Bar() ([]string, error)
    }
    ```
    
    So the user simply returns a string slice, the Thrift library has no 
control over it. Once `Foo` returns, it's too late for Thrift itself to return 
an error, only panic. Speaking of which, panicking in case of ***programmer 
error*** is very common and idiomatic in Go. The standard library is full of 
such panics (e.g search for "misuse" 
[here](https://golang.org/src/sync/waitgroup.go)). I would consider returning a 
non-unique slice for a Thrift set a programming error (and hence deserving a 
panic), but if you disagree, I can update the PR with deduplication in the 
library.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to