Re: [go-nuts] Re: why treat int and []int differently here?

2016-07-17 Thread andrey mirtchovski
> @all, thanks for the explanation!

in my view, all the "details" come from reasoning about Go through the
sieve of other programming languages. nothing wrong in doing that, as
long as the original intention is understood. for me, Go will always
be looked through the sieve of C, in particular the kind of C the
authors wrote for Plan 9. even though some of the decisions may have
looked strange to me at one point or another, summarily Go is much
more complete.

the standard library implementation on the other hand should be looked
through the sieve of Go and Go alone. and perhaps the go1
compatibility guarantee :)

-- 
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] Re: why treat int and []int differently here?

2016-07-17 Thread T L
@all, thanks for the explanation!

Golang is a simple language full of details.

On Sunday, July 17, 2016 at 4:15:12 AM UTC+8, T L wrote:
>
>
> package main
>>
>> func fi(i int) {}
>> func fis(is []int) {}
>>
>> type TI int
>> type TIS []int
>>
>> func main() {
>> var ti TI
>> fi(ti) // cannot use ti (type TI) as type int in argument to fi
>> 
>> var tis TIS
>> fis(tis) // no problems! 
>> }
>>
>>

-- 
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: why treat int and []int differently here?

2016-07-16 Thread Matt Harden
In that code, there is no silent conversion. In AddOne, the constant 1 is
inferred to be of type Int (not int), and so you're just adding Int to Int
to get another Int.

On Sat, Jul 16, 2016 at 5:35 PM pi  wrote:

> Sorry my bad. Forget to add "in many cases" to last sentence.
> https://play.golang.org/p/7MtoscXiFo
>
> воскресенье, 17 июля 2016 г., 2:53:15 UTC+3 пользователь kortschak написал:
>
>> On Sat, 2016-07-16 at 15:36 -0700, pi wrote:
>> > `type` is not `typedef` in Go. `type` introduces completely new type.
>> > Fortunately, Go can cast these types to base type silently, i.e.
>> > explicict
>> > cast int(valueOfTI) is unnecessary.
>>
>> This is not true; a named concrete type is never silently converted to
>> another concrete type.
>>
>> --
> 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.
>

-- 
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: why treat int and []int differently here?

2016-07-16 Thread 'Axel Wagner' via golang-nuts
On Sun, Jul 17, 2016 at 1:52 AM, Dan Kortschak <
dan.kortsc...@adelaide.edu.au> wrote:

> On Sat, 2016-07-16 at 15:36 -0700, pi wrote:
> > `type` is not `typedef` in Go. `type` introduces completely new type.
> > Fortunately, Go can cast these types to base type silently, i.e.
> > explicict
> > cast int(valueOfTI) is unnecessary.
>
> This is not true; a named concrete type is never silently converted to
> another concrete type.
>

Also not true, as OP pointed out ;) A named concrete type is never silently
converted to another *named* concrete type ;)


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

-- 
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: why treat int and []int differently here?

2016-07-16 Thread Dan Kortschak
On Sat, 2016-07-16 at 15:36 -0700, pi wrote:
> `type` is not `typedef` in Go. `type` introduces completely new type. 
> Fortunately, Go can cast these types to base type silently, i.e.
> explicict 
> cast int(valueOfTI) is unnecessary.

This is not true; a named concrete type is never silently converted to
another concrete type.

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