Skip to content

type identity. B0 와 B0 는 같지 않을 수 있다. #323

Open
@dakeshi

Description

@dakeshi
type (
	A0 = []string
	A1 = A0
	A2 = struct{ a, b int }
	A3 = int
	A4 = func(A3, float64) *A0
	A5 = func(x int, _ float64) *[]string
)

type (
	B0 A0
	B1 []string
	B2 struct{ a, b int }
	B3 struct{ a, c int }
	B4 func(int, float64) *B0
	B5 func(x int, y float64) *A1
)

type	C0 = B0

1.9 버전에서는 B0, B0, C0 가 identical type 이라고 설명했습니다. 많은 사람들이 B0 가 중복으로 사용되었기 때문에 typo 에러로 버그 레포팅을 했는데 griesemer 의 설명에 따르면 B0와 B0가 항상 identical type은 아닙니다. 예문에서는 B0와 B0가 identical type이기 때문에 B0, B0, C0 가 identical type 이다 라고 설명하는게 문제가 없다고 언급했습니다.

아래는 griesemer가 설명한 내용입니다.(golang/go#22495 (comment))

That's the whole point: Who says that B0 and B0 are identical types? It needs to be spelled out. The types system is a formal system and it's up to the spec to state the rules. It's not as obvious as it may seem: For instance, for a floating-point value x, it's not a given that x == x (it's not true if x is NaN). Or, more closely related: We cannot write nil == nil. And so forth.
But given the number of bug reports this gets it looks like the point is not coming across, or perhaps it too academic.

그의 설명 이후에도 동일한 내용의 버그 레포팅이 반복되자 독자들의 혼동을 피하기 위해 1.10 에서는
B0, C0 는 identical type 이다라고 구문이 변경되었습니다.

관련 commit: golang/go@c13e0e8

Metadata

Metadata

Assignees

No one assigned

    Labels

    reference참고자료, 보충 설명 issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions