Not really, go packages are just right as they are IMO. I would just like
to be able to refer to that embedded type by name, e.g. to compose parts of
the struct separately, whilst keeping the definition of the larger type
including its embedded types in one place.



On Thursday, 25 August 2016, Justin Israel <justinisr...@gmail.com> wrote:

> Is this effectively just trying to achieve namespacing within a package?
>
> On Thu, Aug 25, 2016 at 11:09 AM Sam Salisbury <samsalisb...@gmail.com
> <javascript:_e(%7B%7D,'cvml','samsalisb...@gmail.com');>> wrote:
>
>> It would just mean that all embedded struct types introduce a new type
>> named "(parent struct type name).(field name)|, that you could use as if it
>> were any other type (albeit with a dot, not currently allowed in type
>> names).
>>
>> Sometimes it's nice to define a type as part of another type to see a
>> deeper structure in one go rather than having to scan around a
>> file/different files, but right now those embedded types are incorrigible
>> for most uses, e.g. defining methods or passing around as exported types.
>>
>> On 24 August 2016 at 23:15, Jan Mercl <0xj...@gmail.com
>> <javascript:_e(%7B%7D,'cvml','0xj...@gmail.com');>> wrote:
>>
>>>
>>>
>>> On Thu, Aug 25, 2016, 00:08 Sam Salisbury <samsalisb...@gmail.com
>>> <javascript:_e(%7B%7D,'cvml','samsalisb...@gmail.com');>> wrote:
>>>
>>>> Would it be nice or nasty for this to work? https://play.golang.org/
>>>> p/iCTKx3gF_2
>>>>
>>>> Copy-pasted:
>>>>
>>>> type Thing struct {
>>>> Embedded struct {
>>>> Name string
>>>> }
>>>> }
>>>>
>>>> func main() {
>>>> x := Thing.Embedded{Name: "Barry"}
>>>> fmt.Println(x.Thing.Name)
>>>> // output:
>>>> // Barry
>>>> }
>>>>
>>>>
>>>> Seems it would be useful to me to be able to do this sometimes,
>>>> especially when consuming other people's code that uses embedded struct
>>>> types.
>>>>
>>>
>>> A field is either named or anonymous. The later case means embedding.
>>> But what a named embedded field would even stand for?
>>>
>>> --
>>>
>>> -j
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "golang-nuts" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to golang-nuts+unsubscr...@googlegroups.com
>> <javascript:_e(%7B%7D,'cvml','golang-nuts%2bunsubscr...@googlegroups.com');>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to