wording in Go tour, methods/19

64 views
Skip to first unread message

Marvin Renich

unread,
Apr 15, 2020, 11:58:11 AM4/15/20
to golang-nuts
In the Go tour at https://tour.golang.org/methods/19 it says

The error type is a built-in interface similar to fmt.Stringer:

The words closest to "similar to" are "built-in interface", implying
that the way error is similar to fmt.Stringer is that it is a built-in
interface, which it clearly isn't. I would be surprised if this is not
a source of confusion to a significant number of programmers who are new
to go and using the tour to get acquainted.

A much better wording would be

The error type is a built-in interface; its definition is similar to
fmt.Stringer:

I don't have a github account, so I can't send feedback using the
feedback button on the page.

...Marvin

Volker Dobler

unread,
Apr 16, 2020, 2:28:06 AM4/16/20
to golang-nuts
On Wednesday, 15 April 2020 17:58:11 UTC+2, Marvin Renich wrote:
In the Go tour at https://tour.golang.org/methods/19 it says

  The error type is a built-in interface similar to fmt.Stringer:

The words closest to "similar to" are "built-in interface", implying
that the way error is similar to fmt.Stringer is that it is a built-in
interface, which it clearly isn't.  I would be surprised if this is not
a source of confusion to a significant number of programmers who are new
to go and using the tour to get acquainted.

I agree that this might be misunderstood in the sense of fmt.Stringer
being built-in too, but if this is commonly misunderstood it probably
is not a long-lasting, problematic confusion (for most purposes it
simply doesn't matter wether fmt.String is a predeclared built-in or
declared in the stdlib).
 
A much better wording would be

  The error type is a built-in interface; its definition is similar to
  fmt.Stringer: 

I think I disagree here. The similarity of error and fmt.Stringer is
both being a one-method interface and this method has the same
signature for both (no arguments, string return) but their _actual_
"definition" is pretty different as one is built-in, the other isn't.

V. 

Marvin Renich

unread,
Apr 16, 2020, 7:57:16 AM4/16/20
to golang-nuts
* Volker Dobler <dr.volke...@gmail.com> [200416 02:28]:
> On Wednesday, 15 April 2020 17:58:11 UTC+2, Marvin Renich wrote:
> >
> > In the Go tour at https://tour.golang.org/methods/19 it says
> >
> > The error type is a built-in interface similar to fmt.Stringer:
>
> I agree that this might be misunderstood in the sense of fmt.Stringer
> being built-in too, but if this is commonly misunderstood it probably
> is not a long-lasting, problematic confusion (for most purposes it
> simply doesn't matter wether fmt.String is a predeclared built-in or
> declared in the stdlib).

Whether the confusion is long lasting or not, it requires re-reading the
statement and possibly looking up the definition of fmt.Stringer to
understand what is being said. Making the statement clearer on initial
read is definitely better.

> > A much better wording would be
> >
> > The error type is a built-in interface; its definition is similar to
> > fmt.Stringer:
>
> I think I disagree here. The similarity of error and fmt.Stringer is
> both being a one-method interface and this method has the same
> signature for both (no arguments, string return) but their _actual_
> "definition" is pretty different as one is built-in, the other isn't.

Okay, then what is the point of saying the two are "similar"? I am
simply advocating that the fact that error is built-in be separated from
any comparison to fmt.Stringer, for whatever comparison you would like
to make. Would you like this better (I don't particularly, but it is
better than what is there now)?

The error type is an interface similar to fmt.Stringer, but it is
built-in:

Making written communication easier to understand is always an important
goal, even if it means being somewhat more verbose. This is especially
true in a tutorial such as the Go tour.

...Marvin

Reply all
Reply to author
Forward
0 new messages