]> Cypherpunks repositories - gostls13.git/commitdiff
go/constant: document that Value.String and ExactString return quoted strings
authorRobert Griesemer <gri@golang.org>
Wed, 7 Sep 2016 00:26:15 +0000 (17:26 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 7 Sep 2016 04:28:35 +0000 (04:28 +0000)
This has always been the case but it was not obvious from the documentation.
The reason for the quoting is that String() may return an abbreviated string,
starting with double-quote (") but ending in ... (w/o a quote). The missing
quote indicates the abbreviation (in contrast to a string ending in ...").

constant.StringVal can be used to obtain the unquoted string of a String Value.

Change-Id: Id0ba45b6ff62b3e024386ba8d907d6b3a4fcb6d7
Reviewed-on: https://go-review.googlesource.com/28576
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/constant/value.go

index ab10ae32998c9966fa2e8741b6e32ad029a63612..90c04df88d7d5c2681c0a43833b1f75346169cb6 100644 (file)
@@ -43,13 +43,14 @@ type Value interface {
        // Kind returns the value kind.
        Kind() Kind
 
-       // String returns a short, human-readable form of the value.
+       // String returns a short, quoted (human-readable) form of the value.
        // For numeric values, the result may be an approximation;
        // for String values the result may be a shortened string.
        // Use ExactString for a string representing a value exactly.
        String() string
 
-       // ExactString returns an exact, printable form of the value.
+       // ExactString returns an exact, quoted (human-readable) form of the value.
+       // If the Value is of Kind String, use StringVal to obtain the unquoted string.
        ExactString() string
 
        // Prevent external implementations.