Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(8642)

Issue 151580043: code review 151580043: go.test/runes: added package for manipulating runes in text.

Can't Edit
Can't Publish+Mail
Start Review
Created:
9 years, 6 months ago by mpvl
Modified:
9 years, 4 months ago
Reviewers:
nigeltao
CC:
nigeltao, r, golang-codereviews
Visibility:
Public.

Description

go.text/runes: added package for manipulating runes in text. Mostly for defining transformer equivalents for functionality found in core's strings and bytes packages. Design points: - Functionilty is now a bit scattered (e.g. in encoding and transform). - RemoveFunc in transform is Remove in this package. The func was a bit misplaced in transform. - Adding these to transform would clutter it too much. Also, the semantics of runes.Map is clearer from the syntax than transform.Map. - Did not use unicode, strings or bytes as package name to avoid conflicts: it is not unlikely these packages will be used together in one file. - Naming of the funcs returning Transformers describe the action performed by the transformer, not the type of Transfomer they return. This is maybe a bit odd, but when adopted as a convention within go.text, it reads quite nicely (compare with cases.Upper, for example). - Used a wrapper around Transformer similar to Caser (Transform migh be a better name). I expect there to be enough use cases for this to warrant it and since all the transforms wrapped in this type don't return errors, the resulting API is much simpler: t := runes.Map(myFunc) s, _, _ := transform.String(t, s) fmt.Println(s) versus fmt.Println(runes.Map(myFunc).String(s)) (runes.Map(myFunc) is fast and does not cause an allocation.)

Patch Set 1 #

Patch Set 2 : diff -r 3aea2a44d35a https://code.google.com/p/go.text #

Patch Set 3 : diff -r 3aea2a44d35a https://code.google.com/p/go.text #

Total comments: 24

Patch Set 4 : diff -r 3aea2a44d35a https://code.google.com/p/go.text #

Patch Set 5 : diff -r 3aea2a44d35a https://code.google.com/p/go.text #

Total comments: 23

Patch Set 6 : diff -r f8db539672d0 https://code.google.com/p/go.text #

Total comments: 53

Patch Set 7 : diff -r f8db539672d0 https://code.google.com/p/go.text #

Patch Set 8 : diff -r f8db539672d0 https://code.google.com/p/go.text #

Total comments: 6

Patch Set 9 : diff -r f8db539672d0 https://code.google.com/p/go.text #

Patch Set 10 : diff -r f8db539672d0 https://code.google.com/p/go.text #

Unified diffs Side-by-side diffs Delta from patch set Stats (+870 lines, -0 lines) Patch
A runes/example_test.go View 1 chunk +46 lines, -0 lines 0 comments Download
A runes/runes.go View 1 chunk +254 lines, -0 lines 0 comments Download
A runes/runes_test.go View 1 chunk +570 lines, -0 lines 0 comments Download

Messages

Total messages: 16
mpvl
Hello nigeltao@golang.org (cc: golang-codereviews@googlegroups.com, r@golang.org), I'd like you to review this change to https://code.google.com/p/go.text
9 years, 6 months ago (2014-10-08 14:00:02 UTC) #1
r
the repo is go.text not go.test. please fix CL subject and remail
9 years, 6 months ago (2014-10-08 18:04:41 UTC) #2
r
https://codereview.appspot.com/151580043/diff/20002/runes/runes.go File runes/runes.go (right): https://codereview.appspot.com/151580043/diff/20002/runes/runes.go#newcode21 runes/runes.go:21: // Validator is a transformer that returns ErrInvalid on ...
9 years, 6 months ago (2014-10-08 18:10:44 UTC) #3
nigeltao
https://codereview.appspot.com/151580043/diff/20002/runes/example_test.go File runes/example_test.go (right): https://codereview.appspot.com/151580043/diff/20002/runes/example_test.go#newcode28 runes/example_test.go:28: replaceHyhpens := runes.Map(func(r rune) rune { Typo in "Hyphens". ...
9 years, 6 months ago (2014-10-09 06:03:59 UTC) #4
mpvl
https://codereview.appspot.com/151580043/diff/20002/runes/example_test.go File runes/example_test.go (right): https://codereview.appspot.com/151580043/diff/20002/runes/example_test.go#newcode28 runes/example_test.go:28: replaceHyhpens := runes.Map(func(r rune) rune { On 2014/10/09 06:03:59, ...
9 years, 6 months ago (2014-10-09 07:45:33 UTC) #5
mpvl
(addressed your comments in the replay to r). On Thu, Oct 9, 2014 at 8:03 ...
9 years, 6 months ago (2014-10-09 07:46:42 UTC) #6
nigeltao
https://codereview.appspot.com/151580043/diff/70001/runes/runes.go File runes/runes.go (right): https://codereview.appspot.com/151580043/diff/70001/runes/runes.go#newcode24 runes/runes.go:24: ValidateWellFormed transform.Transformer = nil // TODO: Validate(nil) If Validate ...
9 years, 6 months ago (2014-10-21 02:45:46 UTC) #7
mpvl
https://codereview.appspot.com/151580043/diff/70001/runes/runes.go File runes/runes.go (right): https://codereview.appspot.com/151580043/diff/70001/runes/runes.go#newcode24 runes/runes.go:24: ValidateWellFormed transform.Transformer = nil // TODO: Validate(nil) On 2014/10/21 ...
9 years, 6 months ago (2014-10-21 16:43:44 UTC) #8
nigeltao
Despite my comments, the code is pretty close to Looking Good. I'm not entirely convinced ...
9 years, 6 months ago (2014-10-22 05:37:45 UTC) #9
mpvl
The argument for the package name "runes" is as follows: - All operations operate on ...
9 years, 6 months ago (2014-10-22 11:22:38 UTC) #10
mpvl
https://codereview.appspot.com/151580043/diff/90001/runes/runes.go File runes/runes.go (right): https://codereview.appspot.com/151580043/diff/90001/runes/runes.go#newcode68 runes/runes.go:68: ReplaceIllFormed Transformer = ReplaceIllFormedWithRune(RuneError) In fact, I've renamed the ...
9 years, 6 months ago (2014-10-22 13:21:39 UTC) #11
r
i'm not convinced runes is the right name either, since by analogy with bytes we'd ...
9 years, 6 months ago (2014-10-22 15:16:01 UTC) #12
nigeltao
LGTM, but wait for r. I'd still cut the API surface down, as it's easier ...
9 years, 6 months ago (2014-10-23 03:48:09 UTC) #13
r
Marcel: Please mail the godoc output for this package. I find that's easier to absorb ...
9 years, 6 months ago (2014-10-23 03:53:09 UTC) #14
mpvl
See below. It may be useful to consider this package together with the two CLs ...
9 years, 6 months ago (2014-10-23 07:36:37 UTC) #15
gobot
9 years, 4 months ago (2014-12-19 05:13:50 UTC) #16
R=close

To the author of this CL:

The Go project has moved to Gerrit Code Review.

If this CL should be continued, please see the latest version of
https://golang.org/doc/contribute.html for instructions on
how to set up Git and the Go project's Gerrit codereview plugin,
and then create a new change with your current code.

If there has been discussion on this CL, please give a link to it
(golang.org/cl/151580043 is best) in the description in your
new CL.

Thanks very much.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b