Skip to content

deprecate StringLike.linesIterator, we have StringLike.lines for that #4997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue Sep 15, 2011 · 13 comments
Closed

deprecate StringLike.linesIterator, we have StringLike.lines for that #4997

scabug opened this issue Sep 15, 2011 · 13 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 15, 2011

StringLike.scala has:

  /** Return all lines in this string in an iterator, excluding trailing line
   *  end characters, i.e. apply `.stripLineEnd` to all lines
   *  returned by `linesWithSeparators`.
   */
  def lines: Iterator[String] = 
    linesWithSeparators map (line => new WrappedString(line).stripLineEnd)

  /** Return all lines in this string in an iterator, excluding trailing line
   *  end characters, i.e. apply `.stripLineEnd` to all lines
   *  returned by `linesWithSeparators`.
   */
  def linesIterator: Iterator[String] = 
    linesWithSeparators map (line => new WrappedString(line).stripLineEnd)

The methods are identical. Surely linesIterator should be deprecated and tell people to use lines instead?

@scabug
Copy link
Author

scabug commented Sep 15, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4997?orig=1
Reporter: @SethTisue
See #5994

@scabug
Copy link
Author

scabug commented Oct 30, 2011

@paulp said:
Since lines is unfortunately ambiguous with the same method in scala.sys.process, it's tempting to go the other way.

@scabug
Copy link
Author

scabug commented Oct 25, 2012

@adriaanm said:
since we can only deprecate on .0 releases, it's now or 2.11.0

@scabug
Copy link
Author

scabug commented Jan 28, 2014

@Ichoran said:
Simon, have you got this one or shall I steal it?

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@soc said:
You can steal it, I haven't had the time to think about it. Paul's comment is certainly valid. Not sure what's the best way here.
If keeping linesIterator would not create any inconsistencies, (e. g. other methods in StringLike return Iterator, without having a method name suffix of "iterator"), I'd slightly favor that approach.

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@SethTisue said:
seems to me that sys.process should bow to core string stuff, rather than vice versa

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@paulp said:
Honestly they should both be forced to give up "lines". sys.process's should be some name involving stdout or standard out or something which distinguishes the "lines" from stderr, and StringLike should use a name which isn't so likely to collide with the library user's choices.

@scabug
Copy link
Author

scabug commented Jan 29, 2014

@som-snytt said:
Yes, process.outputLines, string.linesOfText, plus variants on whether you want autodetect or only NL or only the platform dependent line separator.

I know Rex will make the right naming choices.

OK, since I made the joke, p.outputLines(ending = Auto) [or Newline or EOL]

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@Ichoran said:
StringLike gets .lines because it fits right in with .tails .grouped and a bunch of other methods that return iterators. linesIterator is clearly the odd one out, and there's no other modifier that is clearly in.

@scabug
Copy link
Author

scabug commented Feb 1, 2014

@Ichoran said:
scala/scala#3453

@SethTisue
Copy link
Member

undeprecated for 2.12.7 because of #11125

@scala scala deleted a comment from scabug Sep 20, 2018
@som-snytt
Copy link

som-snytt commented Sep 21, 2018

I'd like to add how wise paulp's comment was about naming. linesIterator is lame because it is semantically void.

Edit:
on domain-pertaining naming, which also expresses something about the lines you're getting,
paulp: sys.process's should be some name involving stdout or standard out or something which distinguishes the "lines" from stderr, and StringLike should use a name which isn't so likely to collide with the library user's choices.
me: process.outputLines, string.linesOfText

@adriaanm
Copy link
Contributor

As it turns out, lame names don't get into conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants