From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <0de965508a7a944ef6bf0c0af1082091@brasstown.quanstro.net> References: <0de965508a7a944ef6bf0c0af1082091@brasstown.quanstro.net> From: minux Date: Sun, 24 May 2015 17:25:54 -0400 Message-ID: To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: multipart/alternative; boundary=001a1144dc220dc15c0516da8bc4 Subject: Re: [9fans] ot: pascal rides again? Topicbox-Message-UUID: 55343212-ead9-11e9-9d60-3106f5b1d025 --001a1144dc220dc15c0516da8bc4 Content-Type: text/plain; charset=UTF-8 On Sun, May 24, 2015 at 11:55 AM, erik quanstrom wrote: > > Uhm I might be mistaken, but I guess [8192]byte is an array, and []byte > are > > slices - therefore they are different types. > > > > yes, exactly. i suppose this implies that different size arrays are not > type compatable > (yea pascal). also the fu := bar[:] looks a lot like the tedious casting > from c, and implies > dynamic allocation of the slice, i'm guessing. > You can also argue that C arrays are pascal style. char x[8192] and char y[4096] do not have compatible types. In fact. how could different array types be really compatible in a C like language? void f(int a[50]); even though you can pass a (pointer to) array of 25 ints, I doubt the function would do the right thing. If you pass both the pointer and the length to the function, then you're just emulating a Go slice (without the capacity). In essence, Go's array is not directly related to C's, it's more like a C array wrapped in a struct. A slice is what C programmers normally use to pass an array. Regarding the boring comment, I agree to some extent. There isn't many fancy features that other languages have, but that's exactly the advantage of Go, and it's the price to pay when you want readability. (i.e. you don't need ~65 pages of style guide just to tell you how to write acceptable code.) --001a1144dc220dc15c0516da8bc4 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Sun, May 24, 2015 at 11:55 AM, erik quanstrom <quanstro@quanstro.ne= t> wrote:
= > Uhm I might be mistaken, but I guess [8192]byte is an array, and []byt= e are
> slices - therefore they are different types.
>

yes, exactly.=C2=A0 i suppose this implies that different size array= s are not type compatable
(yea pascal).=C2=A0 also the fu :=3D bar[:] looks a lot like the tedious ca= sting from c, and implies
dynamic allocation of the slice, i'm guessing.
You can also argue that C arrays are pascal style. char x[8192]= and
char y[4096] do not have compatible types.

In fact. how could different array types be really compatible in a = C like
language?

void f(int a[50]);

even though you can pass a (pointer to) array of 25 in= ts, I doubt the
function would do the right thing.
=
If you pass both the pointer and the length to the function,= then you're
just emulating a Go slice (without the capacity)= .

In essence, Go's array is not directly relat= ed to C's, it's more like a C
array wrapped in a struct. = A slice is what C programmers normally
use to pass an array.

Regarding the boring comment, I agree to some extent. = There isn't
many fancy features that other languages have, bu= t that's exactly the
advantage of Go, and it's the price = to pay when you want readability.
(i.e. you don't need ~65 pa= ges of style guide just to tell you how to
write acceptable code.= )
--001a1144dc220dc15c0516da8bc4--