• Rob Pike's avatar
    fmt.Print*: reimplement to switch on type first. · d482c163
    Rob Pike authored
    This shortens, simplifies and regularizes the code significantly.
    (Improvements to reflect could make another step.)
    Passes all.bash.
    
    One semantic change occurs: The String() method changes
    behavior. It used to run only for string formats such as %s and %q.
    Instead, it now runs whenever the item has the method and the
    result is then processed by the format as a string. Besides the
    regularization, this has three effects:
    
    	1) width is honored for String() items
    	2) %x works for String() items
    	3) implementations of String that merely recur will recur forever
    
    Regarding point 3, example from the updated documentation:
    	type X int
    	func (x X) String() string { return Sprintf("%d", x) }
    should cast the value before recurring:
    	func (x X) String() string { return Sprintf("%d", int(x)) }
    
    R=rsc
    CC=golang-dev
    https://golang.org/cl/1613045
    d482c163
Name
Last commit
Last update
..
archive/tar Loading commit data...
asn1 Loading commit data...
big Loading commit data...
bufio Loading commit data...
bytes Loading commit data...
cmath Loading commit data...
compress Loading commit data...
container Loading commit data...
crypto Loading commit data...
debug Loading commit data...
ebnf Loading commit data...
encoding Loading commit data...
exec Loading commit data...
exp Loading commit data...
expvar Loading commit data...
flag Loading commit data...
fmt Loading commit data...
go Loading commit data...
gob Loading commit data...
hash Loading commit data...
html/testdata/webkit Loading commit data...
http Loading commit data...
image Loading commit data...
io Loading commit data...
json Loading commit data...
log Loading commit data...
math Loading commit data...
mime Loading commit data...
net Loading commit data...
netchan Loading commit data...
nntp Loading commit data...
once Loading commit data...
os Loading commit data...
patch Loading commit data...
path Loading commit data...
rand Loading commit data...
reflect Loading commit data...
regexp Loading commit data...
rpc Loading commit data...
runtime Loading commit data...
scanner Loading commit data...
sort Loading commit data...
strconv Loading commit data...
strings Loading commit data...
sync Loading commit data...
syscall Loading commit data...
syslog Loading commit data...
tabwriter Loading commit data...
template Loading commit data...
testing Loading commit data...
time Loading commit data...
unicode Loading commit data...
unsafe Loading commit data...
utf16 Loading commit data...
utf8 Loading commit data...
websocket Loading commit data...
xml Loading commit data...
Makefile Loading commit data...
deps.bash Loading commit data...