On Sun, May 24, 2015 at 11:55 AM, erik quanstrom <quans...@quanstro.net>
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.)

Reply via email to