Proposal Details
I propose adding the following method to go/types:
IsConstant reports whether tv represents a constant.
func (tv TypeAndValue) IsConstant() bool { return tv.Value != nil }
Calling tv.IsConstant() is clearer than writing tv.Value != nil, and avoids confusion with tv.IsValue(), which tests something different.
Motivation: much code in x/tools uses tv.Value != nil, often with no explanation, making challenging code even harder to understand.
Proposal Details
I propose adding the following method to
go/types:Calling
tv.IsConstant()is clearer than writingtv.Value != nil, and avoids confusion withtv.IsValue(), which tests something different.Motivation: much code in x/tools uses
tv.Value != nil, often with no explanation, making challenging code even harder to understand.