Re: [go-nuts] Why "strings" package exists ?

2018-08-16 Thread isfrog
Thank you, Ian.


在 2018年8月15日星期三 UTC+8下午12:36:31,Ian Lance Taylor写道:
>
> On Tue, Aug 14, 2018 at 7:37 PM,  > wrote: 
> > 
> > Why not define the methods on type "string" ? 
> > I look up the document, strings package handles string with UTF-8 
> encoding. 
> > is it the reason ? 
> > if not, it's design decision or any other reasons ? 
>
> 1. None of the types defined by the language have methods. 
>
> 2. Some of the functions in the strings package, such as strings.Join, 
> don't make a lot of sense as methods. 
>
> 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] Why "strings" package exists ?

2018-08-15 Thread Jan Mercl
On Thu, Aug 16, 2018 at 6:53 AM Kevin Malachowski 
wrote:

> Well, the 'error' type has a method. But none of the other primitives do.

The predeclared 'error' type is an interface. Interfaces do not have
methods. Interfaces only declare method sets.
-- 

-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.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Why "strings" package exists ?

2018-08-15 Thread Kevin Malachowski
Well, the 'error' type has a method. But none of the other primitives do.

-- 
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] Why "strings" package exists ?

2018-08-14 Thread Ian Lance Taylor
On Tue, Aug 14, 2018 at 7:37 PM,   wrote:
>
> Why not define the methods on type "string" ?
> I look up the document, strings package handles string with UTF-8 encoding.
> is it the reason ?
> if not, it's design decision or any other reasons ?

1. None of the types defined by the language have methods.

2. Some of the functions in the strings package, such as strings.Join,
don't make a lot of sense as methods.

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.


[go-nuts] Why "strings" package exists ?

2018-08-14 Thread isfrog
Why not define the methods on type "string" ? 
I look up the document, strings package handles string with UTF-8 encoding. 
is it the reason ? 
if not, it's design decision or any other reasons ?

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