• 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
..
cmd Loading commit data...
lib9 Loading commit data...
libbio Loading commit data...
libcgo Loading commit data...
libmach Loading commit data...
pkg Loading commit data...
Make.386 Loading commit data...
Make.amd64 Loading commit data...
Make.arm Loading commit data...
Make.cmd Loading commit data...
Make.common Loading commit data...
Make.conf Loading commit data...
Make.pkg Loading commit data...
all-arm.bash Loading commit data...
all-nacl.bash Loading commit data...
all.bash Loading commit data...
clean.bash Loading commit data...
env.bash Loading commit data...
make.bash Loading commit data...
quietgcc.bash Loading commit data...
run.bash Loading commit data...
sudo.bash Loading commit data...
version.bash Loading commit data...