8cc の移植 : CとGoを同時に学ぶ for (;;) { int c = get(); if (c == EOF) return; if (c == ' ' || c == '\t') continue; for { c, err := get() if err != nil { return } if c == ' ' || c == '\t' { continue } C Go ● 比較しながら学べる
本家Go: stringの実体 「 ポインタと文字列長の組 」 そうだったのか〜〜 (自分のとちょっと違う) // note this is the runtime representation // of the compilers strings. // // typedef struct // { // uchar array[8]; // pointer to data // uchar nel[4]; // number of elements // } String; var sizeof_String int // runtime sizeof(String)
本家Go: sliceの実体 // note this is the runtime representation // of the compilers arrays. // // typedef struct // { // uchar array[8]; // pointer to data // uchar nel[4]; // number of elements // uchar cap[4]; // allocated number of elements // } Array; var array_array int // runtime offsetof(Array,array) - same for String var array_nel int // runtime offsetof(Array,nel) - same for String var array_cap int // runtime offsetof(Array,cap) var sizeof_Array int // runtime sizeof(Array) slice のことを array と呼んでいる? 命名が紛らわしいのでは? (歴史的事情?)