I didn't add tests for Rat.Scan since it's pretty simple and would essentially just be ...
13 years, 10 months ago
(2011-05-20 21:39:28 UTC)
#2
I didn't add tests for Rat.Scan since it's pretty simple and would
essentially just be testing Rat.SetString, but please let me know if
you disagree.
- Evan
I've uploaded a new patch, but it turned out kind of ugly after adding the ...
13 years, 9 months ago
(2011-05-21 23:12:16 UTC)
#4
I've uploaded a new patch, but it turned out kind of ugly after adding
the longest legal token stuff. I can't think of a way to make it
simpler without making it incorrect, but maybe you can offer a
suggestion or two.
PTAL
- Evan
All comments addressed, but please see one response below. http://codereview.appspot.com/4552056/diff/12001/src/pkg/big/nat.go File src/pkg/big/nat.go (right): http://codereview.appspot.com/4552056/diff/12001/src/pkg/big/nat.go#newcode627 src/pkg/big/nat.go:627: ...
13 years, 9 months ago
(2011-05-24 07:35:38 UTC)
#7
All comments addressed, but please see one response below.
http://codereview.appspot.com/4552056/diff/12001/src/pkg/big/nat.go
File src/pkg/big/nat.go (right):
http://codereview.appspot.com/4552056/diff/12001/src/pkg/big/nat.go#newcode627
src/pkg/big/nat.go:627: // These constants are possible results of nat.scan.
On 2011/05/24 00:44:51, gri wrote:
> I don't think these make a lot of sense with an io.Reader, since partial
results
> are the norm, failures are real errors, and situations where the scan exhaust
> the reader are probably uncommon.
Doesn't Int.Scan need to know whether the whole input was consumed? Otherwise,
it will have to always call s.UnreadRune when err == nil. Most of the time this
is correct, but if we've exhausted the reader, won't this leave behind an extra
rune that we actually used?
On Wed, May 25, 2011 at 5:10 AM, <gri@golang.org> wrote: > I think the UnreadRune ...
13 years, 9 months ago
(2011-05-24 20:19:13 UTC)
#9
On Wed, May 25, 2011 at 5:10 AM, <gri@golang.org> wrote:
> I think the UnreadRune simply has to go into the scan function, where
> you have the information needed and thus can call it only if necessary.
It would be nice to call UnreadRune in nat.scan, but strings.Reader
doesn't have UnreadRune. Int.SetString doesn't actually need to unread
runes since it's all or nothing, but it wouldn't hurt if it were able
to.
I'm hesitant to add UnreadRune to strings.Reader because it will
require a fairly big change to that type, but if you or anyone else
thinks it's worthwhile, I can go that route.
- Evan
Ah, I missed that. This is unfortunate. scan could return an additional argument (the next ...
13 years, 9 months ago
(2011-05-24 22:21:02 UTC)
#10
Ah, I missed that. This is unfortunate.
scan could return an additional argument (the next char) but that
makes it even more complicated. I don't think the current split is
right: (nat) scan should either be able to cleanly use a RuneReader,
or we have to find another approach.
I need to think about this some more.
- gri
On Tue, May 24, 2011 at 1:19 PM, Evan Shaw <chickencha@gmail.com> wrote:
> It would be nice to call UnreadRune in nat.scan, but strings.Reader
> doesn't have UnreadRune. Int.SetString doesn't actually need to unread
> runes since it's all or nothing, but it wouldn't hurt if it were able
> to.
>
> I'm hesitant to add UnreadRune to strings.Reader because it will
> require a fairly big change to that type, but if you or anyone else
> thinks it's worthwhile, I can go that route.
On Wed, May 25, 2011 at 10:20 AM, Robert Griesemer <gri@golang.org> wrote: > scan could ...
13 years, 9 months ago
(2011-05-24 22:43:07 UTC)
#11
On Wed, May 25, 2011 at 10:20 AM, Robert Griesemer <gri@golang.org> wrote:
> scan could return an additional argument (the next char) but that
> makes it even more complicated. I don't think the current split is
> right: (nat) scan should either be able to cleanly use a RuneReader,
> or we have to find another approach.
Another approach I tried but didn't submit was passing a closure to
ScanState.Token. The closure kept track of the state of the scanner,
returning true or false as appropriate. I decided that was worse than
the current approach, though.
- Evan
*** Submitted as http://code.google.com/p/go/source/detail?r=d1eb313a0668 *** big: make Int and Rat implement fmt.Scanner R=gri CC=golang-dev http://codereview.appspot.com/4552056 ...
13 years, 9 months ago
(2011-05-27 22:51:04 UTC)
#16
Issue 4552056: code review 4552056: big: make Int and Rat implement fmt.Scanner
(Closed)
Created 13 years, 10 months ago by eds
Modified 13 years, 9 months ago
Reviewers:
Base URL:
Comments: 32