-j
-j
On Saturday, October 1, 2016 at 4:02:14 PM UTC+8, Jan Mercl wrote:On Sat, Oct 1, 2016 at 9:48 AM T L <tapi...@gmail.com> wrote:> If no two custom named types are identical, why spec says that?Because identical named types do exists. You have already listed them.---j
howerver, the byte and uint8 are defined as followings in internal go src:type byte byte
type uint8 uint8
-j
-j
-j
-j
-j
> but we even don't know how the builtin byte and uint8 are defined?Yes we know, see: https://golang.org/ref/spec#Numeric_types
-j
-----j
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
It *is* possible to define two named types with the same name (which are not identical according to the spec):
On Sat, Oct 1, 2016 at 5:03 PM, Jan Mercl <0xj...@gmail.com> wrote:
On Sat, Oct 1, 2016 at 4:28 PM T L <tapi...@gmail.com> wrote:
> I know this byte and uint8 are identical in syntax.They are identical semantically.
> But they are not defined with TypeSpec style described in the go spec.It's not possible to define all predeclared Go types using Go syntax. The predeclared error type can be defined just normally, for example[0]. But there's no way how to define a byte using valid Go source code. Some basic building blocks must be predefined in every sane programming language. From those basic building blocks other types can be built in source, provided the language supports user defined types at all.> In addition to there is no ways to define identical custom named types,
so I think the text "Two named types are identical if their type names originate in the same TypeSpec." in go spec is meaningless.It's been discussed earlier in this thread that without this "meaningless" specification detail a particular example program would be rejected. It is not, because of this specs sentence. How it could be meaningless then?
> Sorry, my English is not good, I have tried my best to explain my opinion.No problem with your English ;-)
-----j
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...@googlegroups.com.
-j
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
---j
--
I do think that T L has a point. The spec defines the syntax of the language, and TypeSpec refers to a syntactical construct. It is not possible in the syntax of the language to create two named types that originate in the same TypeSpec. We seem to be saying that uint8 and byte originate in the same "TypeSpec", but the "TypeSpec" referred to there is an implementation detail of the compiler, not the syntactical construct defined in the Language Specification.I suggest the sentence be changed but not eliminated, because it is good to point out that two named types cannot be identical if either or both were created in Go code. Perhaps something like "Two named types are never identical, except for the type aliases byte and rune, which are identical to uint8 and uint32 respectively."
T0 and T0 are identical.
--
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+unsubscribe@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
Ok, in fact, this is really a problem about how to comprehend the words in go spec.
There are two different interpretations of the words for the following two questions,
1. what does "the same type-spec" mean?
2. what does "two named types" mean?
Your interpretations:
1. "the same type-spec" <=> the same existence of the type declaration.
2. "two named types" may refer two occurrences of a type. In your example, https://play.golang.org/p/grhDxuVjeP, there are two As in "A(42)", you call them "two named types".
My interpretations:
1. "the same type-spec" <=> same type-specs literally
2. "two named types" means two types come from different type-specs.
If there are two occurrences of a type, they can't be called "two named types". In your example, https://play.golang.org/p/grhDxuVjeP, the two As in "A(42)" are just two occurrences of a same type. I feel it is inappropriate to say they are "two named types".
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
--
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+unsubscribe@googlegroups.com.
Which would imply that something like thistype (Foo intFoo int)might be legal. I don't understand (and thusly disagree) why that would be in any sense "less confusing".
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
On Monday, October 3, 2016 at 2:42:30 PM UTC+8, Axel Wagner wrote:Which would imply that something like thistype (Foo intFoo int)might be legal. I don't understand (and thusly disagree) why that would be in any sense "less confusing".
I confuse again.
In your before comments, you interpretate "the same type-spec" must be the only occurrence of a type-spec, and can't be two occurrences of same type-spec in texts.
But now you interpretate "the same type-decl" can be two occurrences of same type-decl in texts.
I really don't know my English understanding is right or not, now, again.
Besides this, in fact, in the example you provide, https://play.golang.org/p/PmkcvdNQnx,
there are two same (in texts) type declarations, they are both legal.
And why does "the same type-decl" will imply "type (Foo int; Foo int)", but "the same type-spec" will not make the imply?
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
The only difference between talking about "TypeDecl" and "TypeSpec" is, that it distinguishestype (Foo intBar int)fromtype Foo inttype Bar int