http://code.google.com/p/pharo/issues/detail?id=6807

Stef

> A total number of lines in string should be:
> one + number of line separators found.
> 
> Explanation: a 'String cr/ crlf' stands for 'line separator'.
> By definition, a separator, is thing which separates two others.. i
> mean, there is no way how you can use 'separator' term
> without having TWO things which it separates.
> 
> The problem is that #lines does not follows common sense:
> 
> (String empty, String cr, String empty) lines size 1
> 
> so, our line separator "separates" one thing :)
> It means that we overload the definition:
> - a line separator separates two lines unless it is at the end of text.
> 
> But think , how dearly this 'unless' will costs in terms of implementation!
> Everywhere where you may need to handle text, you should put this
> extra rule, and if you forget it,
> you will be punished..
> 
> 
> Here what various #lines produces:
> 
> ( 'A' ) lines size 1
> ( 'A', String cr ) lines size 1   !!oops!!.
> 
> ( String cr,  'A' ) lines size 2
> ( 'A', String cr,  'A' ) lines size 2
> 
> ( 'A', String cr,  'A', String cr ) lines size 2
> ( 'A', String cr,  'A', String cr ) lines size 2   !!oops!!
> 
> You may think this is fine, but lets look at the problem from another angle:
> 
> self assert: (string1, String cr, string2) lineCount >= 2
> 
> The 'string1, String cr, string2' above is an insertion operation.
> We inserting a line separator between two arbitrary strings.
> Now, in what universe the total number of lines may not get increased
> after such insertion?
> 
> So, it is simply inconsistent. Or maybe you happy to put extra code
> everywhere where you handling text, to do a special handling if last
> character is line separator?
> But we can avoid all that mess it in a first place, if we obey to common 
> sense.
> 
> -- 
> Best regards,
> Igor Stasenko.
> 


Reply via email to