Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2654)

Issue 58540044: go.tools/go/types: export Comparable and Assertable, si... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by gmk
Modified:
10 years, 2 months ago
Reviewers:
gri, adonovan
CC:
gri, golang-codereviews
Visibility:
Public.

Description

go.tools/go/types: export Comparable and Assertable, simplify Implements The "static bool" parameter to Implements was confusing; typically we think about interface implementation and type assertion as separate but related concepts, but here they were merged.

Patch Set 1 #

Patch Set 2 : diff -r c17fe8df55f0 https://code.google.com/p/go.tools #

Total comments: 3

Patch Set 3 : diff -r 1a4cb01125fd https://code.google.com/p/go.tools #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+18 lines, -22 lines) Patch
M go/types/api.go View 1 2 2 chunks +9 lines, -14 lines 2 comments Download
M go/types/expr.go View 1 1 chunk +1 line, -1 line 0 comments Download
M go/types/lookup.go View 1 1 chunk +1 line, -1 line 0 comments Download
M go/types/operand.go View 1 1 chunk +1 line, -1 line 0 comments Download
M go/types/predicates.go View 1 2 2 chunks +5 lines, -4 lines 0 comments Download
M go/types/typexpr.go View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 10
gri
LGTM
10 years, 2 months ago (2014-01-31 23:06:01 UTC) #1
gri
FYI. https://codereview.appspot.com/58540044/diff/20001/go/types/api.go File go/types/api.go (right): https://codereview.appspot.com/58540044/diff/20001/go/types/api.go#newcode238 go/types/api.go:238: // Comparable reports whether values of type T ...
10 years, 2 months ago (2014-01-31 23:17:46 UTC) #2
gmk
I've signed the CLA, now. MissingMethod is still a little confusing. Some options: 1. At ...
10 years, 2 months ago (2014-02-01 21:09:33 UTC) #3
gri
LGTM
10 years, 2 months ago (2014-02-03 19:07:01 UTC) #4
gri
*** Submitted as https://code.google.com/p/go/source/detail?r=eaffe09e3f17&repo=tools *** go.tools/go/types: export Comparable and Assertable, simplify Implements The "static bool" ...
10 years, 2 months ago (2014-02-03 19:21:03 UTC) #5
adonovan
https://codereview.appspot.com/58540044/diff/40001/go/types/api.go File go/types/api.go (right): https://codereview.appspot.com/58540044/diff/40001/go/types/api.go#newcode227 go/types/api.go:227: func Assertable(V *Interface, T Type) bool { Can we ...
10 years, 2 months ago (2014-02-03 20:22:08 UTC) #6
gmk
https://codereview.appspot.com/58540044/diff/40001/go/types/api.go File go/types/api.go (right): https://codereview.appspot.com/58540044/diff/40001/go/types/api.go#newcode227 go/types/api.go:227: func Assertable(V *Interface, T Type) bool { On 2014/02/03 ...
10 years, 2 months ago (2014-02-03 20:43:35 UTC) #7
adonovan
On 2014/02/03 20:43:35, gmk wrote: > https://codereview.appspot.com/58540044/diff/40001/go/types/api.go > File go/types/api.go (right): > > https://codereview.appspot.com/58540044/diff/40001/go/types/api.go#newcode227 > ...
10 years, 2 months ago (2014-02-03 21:27:26 UTC) #8
gmk
On Mon, Feb 3, 2014 at 10:27 PM, <adonovan@google.com> wrote: > There seems to be ...
10 years, 2 months ago (2014-02-03 22:17:37 UTC) #9
adonovan
10 years, 2 months ago (2014-02-03 22:26:00 UTC) #10
On 2014/02/03 22:17:37, gmk wrote:
> On Mon, Feb 3, 2014 at 10:27 PM, <mailto:adonovan@google.com> wrote:
> > Binary relations are a poor fit for single-dispatch methods and are most
> > naturally defined as a single, recursive standalone function, so why not
> > expose them that way?  Also I'd rather not bloat the interface.
>
> I don't see what you mean.  I was only thinking about the clarity of code:
> x.AssignableTo(y) is unambiguous.  It would be the most "natural" syntax.
>
> I've had similar feelings about not bloating interfaces, but on reflection
> I don't think they're grounded in this case.  The Type interface isn't
> meant to be implemented externally, so adding methods to it doesn't place
> extra burden on clients.

Fair point.


> (However, I find Type.Underlying to be unwelcome
> as it essentially wraps a type assertion that can be implemented in a
> 4-line function in client code.  Also, it collides with the field
> Named.Underlying when that one is exported.)

It's not just a type assertion, it's a condition too, so it means you can no
longer write T.Underlying() as a single expression, which I must have used at
least a hundred times in {go/{ssa,pointer},oracle}.

Agree about the collision.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b