Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Ian Lance Taylor
On Thu, Apr 18, 2019 at 9:17 AM Jan Mercl <0xj...@gmail.com> wrote:
>
> On Thu, Apr 18, 2019 at 6:07 PM Jamil Djadala  wrote:
> >
> > On Thu, 18 Apr 2019 07:44:53 -0700 (PDT)
> > peterGo  wrote:
> >
> > > Cgo translates C types into equivalent unexported Go types.
> > > https://golang.org/cmd/cgo/
> >
> >
> > But then, definition of new methods on non-local types is forbidden.
> > Why it is enabled for cgo types ?
>
> Unexported type cannot be non-local. "C" is not an import path, it
> denotes a pseudo package with special treatment.

That said, I have to agree that defining methods on types defined by
cgo is never necessary and can only cause confusion.  And cgo could
report an error when it sees it.  So please consider opening an issue
to change cmd/cgo to issue an error for an attempt to define a method
on a type defined in the C pseudo-package.  Thanks.

Ian

-- 
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.


Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Jan Mercl
On Thu, Apr 18, 2019 at 6:07 PM Jamil Djadala  wrote:
>
> On Thu, 18 Apr 2019 07:44:53 -0700 (PDT)
> peterGo  wrote:
>
> > Cgo translates C types into equivalent unexported Go types.
> > https://golang.org/cmd/cgo/
>
>
> But then, definition of new methods on non-local types is forbidden.
> Why it is enabled for cgo types ?

Unexported type cannot be non-local. "C" is not an import path, it
denotes a pseudo package with special treatment.

-- 
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.


Re: [go-nuts] Re: methods on C types

2019-04-18 Thread Jamil Djadala
On Thu, 18 Apr 2019 07:44:53 -0700 (PDT)
peterGo  wrote:

> Cgo translates C types into equivalent unexported Go types.
> https://golang.org/cmd/cgo/


But then, definition of new methods on non-local types is forbidden.
Why it is enabled for cgo types ? 

-- 
Jamil Djadala

-- 
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.